diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ArmGrafanaModelFactory.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ArmGrafanaModelFactory.cs index 45c781e4e4e2..9e61d52a288b 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ArmGrafanaModelFactory.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ArmGrafanaModelFactory.cs @@ -8,43 +8,45 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure; using Azure.Core; +using Azure.ResourceManager.Grafana; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.Grafana.Models { - /// Model factory for models. + /// A factory class for creating instances of the models for mocking. public static partial class ArmGrafanaModelFactory { - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. + + /// The grafana resource type. + /// 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. /// Properties specific to the grafana resource. /// The Sku of the grafana resource. + /// Resource tags. + /// The geo-location where the resource lives. /// The managed service identities assigned to this resource. /// A new instance for mocking. - public static ManagedGrafanaData ManagedGrafanaData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, ManagedGrafanaProperties properties = null, ManagedGrafanaSku sku = null, ManagedServiceIdentity identity = null) + public static ManagedGrafanaData ManagedGrafanaData(string id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, ManagedGrafanaProperties properties = default, ManagedGrafanaSku sku = default, IDictionary tags = default, string location = default, ManagedServiceIdentity identity = default) { - tags ??= new Dictionary(); + tags ??= new ChangeTrackingDictionary(); return new ManagedGrafanaData( id, name, resourceType, systemData, - tags, - location, + additionalBinaryDataProperties: null, properties, sku, - identity, - serializedAdditionalRawData: null); + tags, + location, + identity); } - /// Initializes a new instance of . /// Provisioning state of the resource. /// The Grafana software version. /// The endpoint of the Grafana instance. @@ -56,18 +58,17 @@ public static ManagedGrafanaData ManagedGrafanaData(ResourceIdentifier id = null /// List of outbound IPs if deterministicOutboundIP is enabled. /// The private endpoint connections of the Grafana instance. /// Scope for dns deterministic name hash calculation. - /// GrafanaIntegrations is a bundled observability experience (e.g. pre-configured data source, tailored Grafana dashboards, alerting defaults) for common monitoring scenarios. + /// Gets the MonitorWorkspaceIntegrations. /// Enterprise settings of a Grafana instance. /// Server configurations of a Grafana instance. /// Installed plugin list of the Grafana instance. Key is plugin id, value is plugin definition. /// The major Grafana software version to target. /// A new instance for mocking. - public static ManagedGrafanaProperties ManagedGrafanaProperties(GrafanaProvisioningState? provisioningState = null, string grafanaVersion = null, string endpoint = null, GrafanaPublicNetworkAccess? publicNetworkAccess = null, GrafanaZoneRedundancy? zoneRedundancy = null, GrafanaApiKey? apiKey = null, GrafanaCreatorCanAdmin? creatorCanAdmin = null, DeterministicOutboundIP? deterministicOutboundIP = null, IEnumerable outboundIPs = null, IEnumerable privateEndpointConnections = null, AutoGeneratedDomainNameLabelScope? autoGeneratedDomainNameLabelScope = null, IEnumerable monitorWorkspaceIntegrations = null, EnterpriseConfigurations enterpriseConfigurations = null, GrafanaConfigurations grafanaConfigurations = null, IDictionary grafanaPlugins = null, string grafanaMajorVersion = null) + public static ManagedGrafanaProperties ManagedGrafanaProperties(GrafanaProvisioningState? provisioningState = default, string grafanaVersion = default, string endpoint = default, GrafanaPublicNetworkAccess? publicNetworkAccess = default, GrafanaZoneRedundancy? zoneRedundancy = default, GrafanaApiKey? apiKey = default, GrafanaCreatorCanAdmin? creatorCanAdmin = default, DeterministicOutboundIP? deterministicOutboundIP = default, IEnumerable outboundIPs = default, IEnumerable privateEndpointConnections = default, AutoGeneratedDomainNameLabelScope? autoGeneratedDomainNameLabelScope = default, IEnumerable monitorWorkspaceIntegrations = default, EnterpriseConfigurations enterpriseConfigurations = default, GrafanaConfigurations grafanaConfigurations = default, IDictionary grafanaPlugins = default, string grafanaMajorVersion = default) { - outboundIPs ??= new List(); - privateEndpointConnections ??= new List(); - monitorWorkspaceIntegrations ??= new List(); - grafanaPlugins ??= new Dictionary(); + outboundIPs ??= new ChangeTrackingList(); + privateEndpointConnections ??= new ChangeTrackingList(); + grafanaPlugins ??= new ChangeTrackingDictionary(); return new ManagedGrafanaProperties( provisioningState, @@ -78,137 +79,176 @@ public static ManagedGrafanaProperties ManagedGrafanaProperties(GrafanaProvision apiKey, creatorCanAdmin, deterministicOutboundIP, - outboundIPs?.ToList(), - privateEndpointConnections?.ToList(), + outboundIPs.ToList(), + privateEndpointConnections.ToList(), autoGeneratedDomainNameLabelScope, - monitorWorkspaceIntegrations != null ? new GrafanaIntegrations(monitorWorkspaceIntegrations?.ToList(), serializedAdditionalRawData: null) : null, + monitorWorkspaceIntegrations is null ? default : new GrafanaIntegrations((monitorWorkspaceIntegrations ?? new ChangeTrackingList()).ToList(), null), enterpriseConfigurations, grafanaConfigurations, grafanaPlugins, grafanaMajorVersion, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The resource of private end point. + /// 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. /// A collection of information about the state of the connection between service consumer and provider. /// The private endpoint connection group ids. /// The provisioning state of the private endpoint connection resource. + /// The resource identifier of the private endpoint. /// A new instance for mocking. - public static GrafanaPrivateEndpointConnectionData GrafanaPrivateEndpointConnectionData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ResourceIdentifier privateEndpointId = null, GrafanaPrivateLinkServiceConnectionState connectionState = null, IEnumerable groupIds = null, GrafanaPrivateEndpointConnectionProvisioningState? provisioningState = null) + public static GrafanaPrivateEndpointConnectionData GrafanaPrivateEndpointConnectionData(string id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, GrafanaPrivateLinkServiceConnectionState connectionState = default, IEnumerable groupIds = default, GrafanaPrivateEndpointConnectionProvisioningState? provisioningState = default, string privateEndpointId = default) { - groupIds ??= new List(); - return new GrafanaPrivateEndpointConnectionData( id, name, resourceType, systemData, - privateEndpointId != null ? ResourceManagerModelFactory.SubResource(privateEndpointId) : null, - connectionState, - groupIds?.ToList(), - provisioningState, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null, + connectionState is null && groupIds is null && provisioningState is null && privateEndpointId is null ? default : new PrivateEndpointConnectionProperties(new PrivateEndpoint(privateEndpointId, null), connectionState, (groupIds ?? new ChangeTrackingList()).ToList(), provisioningState, null)); } - /// Initializes a new instance of . + /// Plugin of Grafana. /// Grafana plugin id. /// A new instance for mocking. - public static GrafanaPlugin GrafanaPlugin(string pluginId = null) + public static GrafanaPlugin GrafanaPlugin(string pluginId = default) + { + return new GrafanaPlugin(pluginId, additionalBinaryDataProperties: null); + } + + /// The parameters for a PATCH request to a grafana resource. + /// + /// The managed identity of the grafana resource. + /// The new tags of the grafana resource. + /// Properties specific to the managed grafana resource. + /// A new instance for mocking. + public static ManagedGrafanaPatch ManagedGrafanaPatch(ManagedGrafanaSku sku = default, ManagedServiceIdentity identity = default, IDictionary tags = default, ManagedGrafanaPatchProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new ManagedGrafanaPatch(sku, identity, tags, properties, additionalBinaryDataProperties: null); + } + + /// The zone redundancy setting of the Grafana instance. + /// The api key setting of the Grafana instance. + /// The creator will have admin access for the Grafana instance. + /// Whether a Grafana instance uses deterministic outbound IPs. + /// Indicate the state for enable or disable traffic over the public interface. + /// Gets the MonitorWorkspaceIntegrations. + /// Enterprise settings of a Grafana instance. + /// Server configurations of a Grafana instance. + /// Update of Grafana plugin. Key is plugin id, value is plugin definition. If plugin definition is null, plugin with given plugin id will be removed. Otherwise, given plugin will be installed. + /// The major Grafana software version to target. + /// A new instance for mocking. + public static ManagedGrafanaPatchProperties ManagedGrafanaPatchProperties(GrafanaZoneRedundancy? zoneRedundancy = default, GrafanaApiKey? apiKey = default, GrafanaCreatorCanAdmin? creatorCanAdmin = default, DeterministicOutboundIP? deterministicOutboundIP = default, GrafanaPublicNetworkAccess? publicNetworkAccess = default, IEnumerable monitorWorkspaceIntegrations = default, EnterpriseConfigurations enterpriseConfigurations = default, GrafanaConfigurations grafanaConfigurations = default, IDictionary grafanaPlugins = default, string grafanaMajorVersion = default) { - return new GrafanaPlugin(pluginId, serializedAdditionalRawData: null); + grafanaPlugins ??= new ChangeTrackingDictionary(); + + return new ManagedGrafanaPatchProperties( + zoneRedundancy, + apiKey, + creatorCanAdmin, + deterministicOutboundIP, + publicNetworkAccess, + monitorWorkspaceIntegrations is null ? default : new GrafanaIntegrations((monitorWorkspaceIntegrations ?? new ChangeTrackingList()).ToList(), null), + enterpriseConfigurations, + grafanaConfigurations, + grafanaPlugins, + grafanaMajorVersion, + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Enterprise details of a Grafana instance. /// SaaS subscription details of a Grafana instance. /// The allocation details of the per subscription free trial slot of the subscription. /// A new instance for mocking. - public static EnterpriseDetails EnterpriseDetails(SaasSubscriptionDetails saasSubscriptionDetails = null, MarketplaceTrialQuota marketplaceTrialQuota = null) + public static EnterpriseDetails EnterpriseDetails(SaasSubscriptionDetails saasSubscriptionDetails = default, MarketplaceTrialQuota marketplaceTrialQuota = default) { - return new EnterpriseDetails(saasSubscriptionDetails, marketplaceTrialQuota, serializedAdditionalRawData: null); + return new EnterpriseDetails(saasSubscriptionDetails, marketplaceTrialQuota, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// SaaS subscription details of a Grafana instance. /// The plan Id of the SaaS subscription. /// The offer Id of the SaaS subscription. /// The publisher Id of the SaaS subscription. /// The billing term of the SaaS Subscription. /// A new instance for mocking. - public static SaasSubscriptionDetails SaasSubscriptionDetails(string planId = null, string offerId = null, string publisherId = null, SubscriptionTerm term = null) + public static SaasSubscriptionDetails SaasSubscriptionDetails(string planId = default, string offerId = default, string publisherId = default, SubscriptionTerm term = default) { - return new SaasSubscriptionDetails(planId, offerId, publisherId, term, serializedAdditionalRawData: null); + return new SaasSubscriptionDetails(planId, offerId, publisherId, term, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The current billing term of the SaaS Subscription. /// The unit of the billing term. /// The date and time in UTC of when the billing term starts. /// The date and time in UTC of when the billing term ends. /// A new instance for mocking. - public static SubscriptionTerm SubscriptionTerm(string termUnit = null, DateTimeOffset? startOn = null, DateTimeOffset? endOn = null) + public static SubscriptionTerm SubscriptionTerm(string termUnit = default, DateTimeOffset? startOn = default, DateTimeOffset? endOn = default) { - return new SubscriptionTerm(termUnit, startOn, endOn, serializedAdditionalRawData: null); + return new SubscriptionTerm(termUnit, startOn, endOn, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The allocation details of the per subscription free trial slot of the subscription. /// Available enterprise promotion for the subscription. /// Resource Id of the Grafana resource which is doing the trial. /// The date and time in UTC of when the trial starts. /// The date and time in UTC of when the trial ends. /// A new instance for mocking. - public static MarketplaceTrialQuota MarketplaceTrialQuota(AvailablePromotion? availablePromotion = null, ResourceIdentifier grafanaResourceId = null, DateTimeOffset? trialStartOn = null, DateTimeOffset? trialEndOn = null) + public static MarketplaceTrialQuota MarketplaceTrialQuota(AvailablePromotion? availablePromotion = default, ResourceIdentifier grafanaResourceId = default, DateTimeOffset? trialStartOn = default, DateTimeOffset? trialEndOn = default) { - return new MarketplaceTrialQuota(availablePromotion, grafanaResourceId, trialStartOn, trialEndOn, serializedAdditionalRawData: null); + return new MarketplaceTrialQuota(availablePromotion, grafanaResourceId, trialStartOn, trialEndOn, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The GrafanaAvailablePluginListResponse. + /// + /// + /// A new instance for mocking. + public static GrafanaAvailablePluginListResponse GrafanaAvailablePluginListResponse(IEnumerable value = default, string nextLink = default) + { + value ??= new ChangeTrackingList(); + + return new GrafanaAvailablePluginListResponse(value.ToList(), nextLink, additionalBinaryDataProperties: null); + } + + /// Available plugins of grafana. /// Grafana plugin id. /// Grafana plugin display name. /// Grafana plugin type. /// Grafana plugin author/publisher name. /// A new instance for mocking. - public static GrafanaAvailablePlugin GrafanaAvailablePlugin(string pluginId = null, string name = null, string type = null, string author = null) + public static GrafanaAvailablePlugin GrafanaAvailablePlugin(string pluginId = default, string name = default, string @type = default, string author = default) { - return new GrafanaAvailablePlugin(pluginId, name, type, author, serializedAdditionalRawData: null); + return new GrafanaAvailablePlugin(pluginId, name, @type, author, 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. /// Provisioning state of the resource. /// The private link resource group id. /// The private link resource required member names. /// The private link resource Private link DNS zone name. /// A new instance for mocking. - public static GrafanaPrivateLinkResourceData GrafanaPrivateLinkResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, GrafanaProvisioningState? provisioningState = null, string groupId = null, IEnumerable requiredMembers = null, IEnumerable requiredZoneNames = null) + public static GrafanaPrivateLinkResourceData GrafanaPrivateLinkResourceData(string id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, GrafanaProvisioningState? provisioningState = default, string groupId = default, IEnumerable requiredMembers = default, IEnumerable requiredZoneNames = default) { - requiredMembers ??= new List(); - requiredZoneNames ??= new List(); - return new GrafanaPrivateLinkResourceData( id, name, resourceType, systemData, - provisioningState, - groupId, - requiredMembers?.ToList(), - requiredZoneNames?.ToList(), - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null, + provisioningState is null && groupId is null && requiredMembers is null && requiredZoneNames is null ? default : new GrafanaPrivateLinkResourceProperties(provisioningState, groupId, (requiredMembers ?? new ChangeTrackingList()).ToList(), (requiredZoneNames ?? new ChangeTrackingList()).ToList(), null)); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. /// Provisioning state of the resource. /// The ARM resource ID of the resource for which the managed private endpoint is pointing to. /// The region of the resource to which the managed private endpoint is pointing to. @@ -218,97 +258,154 @@ public static GrafanaPrivateLinkResourceData GrafanaPrivateLinkResourceData(Reso /// The URL of the data store behind the private link service. It would be the URL in the Grafana data source configuration page without the protocol and port. /// The private IP of private endpoint after approval. This property is empty before connection is approved. /// A new instance for mocking. - public static ManagedPrivateEndpointModelData ManagedPrivateEndpointModelData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, GrafanaProvisioningState? provisioningState = null, ResourceIdentifier privateLinkResourceId = null, string privateLinkResourceRegion = null, IEnumerable groupIds = null, string requestMessage = null, ManagedPrivateEndpointConnectionState connectionState = null, Uri privateLinkServiceUri = null, string privateLinkServicePrivateIP = null) + public static ManagedPrivateEndpointModelData ManagedPrivateEndpointModelData(string id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, GrafanaProvisioningState? provisioningState = default, ResourceIdentifier privateLinkResourceId = default, string privateLinkResourceRegion = default, IEnumerable groupIds = default, string requestMessage = default, ManagedPrivateEndpointConnectionState connectionState = default, Uri privateLinkServiceUri = default, string privateLinkServicePrivateIP = default) { - tags ??= new Dictionary(); - groupIds ??= new List(); + tags ??= new ChangeTrackingDictionary(); return new ManagedPrivateEndpointModelData( id, name, resourceType, systemData, + additionalBinaryDataProperties: null, tags, location, - provisioningState, - privateLinkResourceId, - privateLinkResourceRegion, - groupIds?.ToList(), - requestMessage, - connectionState, - privateLinkServiceUri, - privateLinkServicePrivateIP, - serializedAdditionalRawData: null); + provisioningState is null && privateLinkResourceId is null && privateLinkResourceRegion is null && groupIds is null && requestMessage is null && connectionState is null && privateLinkServiceUri is null && privateLinkServicePrivateIP is null ? default : new ManagedPrivateEndpointModelProperties( + provisioningState, + privateLinkResourceId, + privateLinkResourceRegion, + (groupIds ?? new ChangeTrackingList()).ToList(), + requestMessage, + connectionState, + privateLinkServiceUri, + privateLinkServicePrivateIP, + null)); } - /// Initializes a new instance of . + /// The state of managed private endpoint connection. /// The approval/rejection status of managed private endpoint connection. /// Gets or sets the reason for approval/rejection of the connection. /// A new instance for mocking. - public static ManagedPrivateEndpointConnectionState ManagedPrivateEndpointConnectionState(ManagedPrivateEndpointConnectionStatus? status = null, string description = null) + public static ManagedPrivateEndpointConnectionState ManagedPrivateEndpointConnectionState(ManagedPrivateEndpointConnectionStatus? status = default, string description = default) + { + return new ManagedPrivateEndpointConnectionState(status, description, additionalBinaryDataProperties: null); + } + + /// The parameters for a PATCH request to a managed private endpoint. + /// The new tags of the managed private endpoint. + /// A new instance for mocking. + public static ManagedPrivateEndpointModelPatch ManagedPrivateEndpointModelPatch(IDictionary tags = default) { - return new ManagedPrivateEndpointConnectionState(status, description, serializedAdditionalRawData: null); + tags ??= new ChangeTrackingDictionary(); + + return new ManagedPrivateEndpointModelPatch(tags, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. + /// The integration fabric resource type. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. /// /// A new instance for mocking. - public static GrafanaIntegrationFabricData GrafanaIntegrationFabricData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, GrafanaIntegrationFabricProperties properties = null) + public static GrafanaIntegrationFabricData GrafanaIntegrationFabricData(string id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, GrafanaIntegrationFabricProperties properties = default) { - tags ??= new Dictionary(); + tags ??= new ChangeTrackingDictionary(); return new GrafanaIntegrationFabricData( id, name, resourceType, systemData, + additionalBinaryDataProperties: null, tags, location, - properties, - serializedAdditionalRawData: null); + properties); } - /// Initializes a new instance of . + /// The GrafanaIntegrationFabricProperties. /// Provisioning state of the resource. /// The resource Id of the Azure resource being integrated with Azure Managed Grafana. E.g., an Azure Kubernetes Service cluster. /// The resource Id of the Azure resource which is used to configure Grafana data source. E.g., an Azure Monitor Workspace, an Azure Data Explorer cluster, etc. /// A list of integration scenarios covered by this integration fabric. /// A new instance for mocking. - public static GrafanaIntegrationFabricProperties GrafanaIntegrationFabricProperties(GrafanaProvisioningState? provisioningState = null, ResourceIdentifier targetResourceId = null, ResourceIdentifier dataSourceResourceId = null, IEnumerable scenarios = null) + public static GrafanaIntegrationFabricProperties GrafanaIntegrationFabricProperties(GrafanaProvisioningState? provisioningState = default, ResourceIdentifier targetResourceId = default, ResourceIdentifier dataSourceResourceId = default, IEnumerable scenarios = default) + { + scenarios ??= new ChangeTrackingList(); + + return new GrafanaIntegrationFabricProperties(provisioningState, targetResourceId, dataSourceResourceId, scenarios.ToList(), additionalBinaryDataProperties: null); + } + + /// The new tags of the Integration Fabric resource. + /// The new integration scenarios covered by this integration fabric. + /// A new instance for mocking. + public static GrafanaIntegrationFabricPatch GrafanaIntegrationFabricPatch(IDictionary tags = default, IEnumerable integrationFabricPropertiesUpdateParametersScenarios = default) { - scenarios ??= new List(); + tags ??= new ChangeTrackingDictionary(); - return new GrafanaIntegrationFabricProperties(provisioningState, targetResourceId, dataSourceResourceId, scenarios?.ToList(), serializedAdditionalRawData: null); + return new GrafanaIntegrationFabricPatch(tags, integrationFabricPropertiesUpdateParametersScenarios is null ? default : new IntegrationFabricPropertiesUpdateParameters((integrationFabricPropertiesUpdateParametersScenarios ?? new ChangeTrackingList()).ToList(), null), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. /// Provisioning state of the resource. /// A new instance for mocking. - public static ManagedDashboardData ManagedDashboardData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, GrafanaProvisioningState? provisioningState = null) + public static ManagedDashboardData ManagedDashboardData(string id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, GrafanaProvisioningState? provisioningState = default) { - tags ??= new Dictionary(); + tags ??= new ChangeTrackingDictionary(); return new ManagedDashboardData( id, name, resourceType, systemData, + additionalBinaryDataProperties: null, tags, location, - provisioningState, - serializedAdditionalRawData: null); + provisioningState is null ? default : new ManagedDashboardProperties(provisioningState, null)); + } + + /// The parameters for a PATCH request to a managed dashboard resource. + /// The new tags of the managed dashboard resource. + /// A new instance for mocking. + public static ManagedDashboardPatch ManagedDashboardPatch(IDictionary tags = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new ManagedDashboardPatch(tags, additionalBinaryDataProperties: null); + } + + /// The dashboard definition resource type. + /// 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. + /// Properties specific to the dashboard definition resource. + /// A new instance for mocking. + public static DashboardDefinitionData DashboardDefinitionData(string id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, DashboardDefinitionProperties properties = default) + { + return new DashboardDefinitionData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// Properties specific to the dashboard definition. + /// The dashboard definition data in JSON format. + /// The provisioning state of the dashboard definition resource. + /// A new instance for mocking. + public static DashboardDefinitionProperties DashboardDefinitionProperties(string serializedData = default, GrafanaProvisioningState? provisioningState = default) + { + return new DashboardDefinitionProperties(serializedData, provisioningState, additionalBinaryDataProperties: null); } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/DashboardDefinitionsGetAllAsyncCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/DashboardDefinitionsGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..54a1e0cfa32c --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/DashboardDefinitionsGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class DashboardDefinitionsGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly DashboardDefinitions _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _dashboardName; + private readonly RequestContext _context; + + /// Initializes a new instance of DashboardDefinitionsGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The DashboardDefinitions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Azure Managed Dashboard. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public DashboardDefinitionsGetAllAsyncCollectionResultOfT(DashboardDefinitions client, string subscriptionId, string resourceGroupName, string dashboardName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _dashboardName = dashboardName; + _context = context; + } + + /// Gets the pages of DashboardDefinitionsGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of DashboardDefinitionsGetAllAsyncCollectionResultOfT 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; + } + DashboardDefinitionListResponse result = DashboardDefinitionListResponse.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _dashboardName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _dashboardName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DashboardDefinitionCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/DashboardDefinitionsGetAllCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/DashboardDefinitionsGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..751f32f09e30 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/DashboardDefinitionsGetAllCollectionResultOfT.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class DashboardDefinitionsGetAllCollectionResultOfT : Pageable + { + private readonly DashboardDefinitions _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _dashboardName; + private readonly RequestContext _context; + + /// Initializes a new instance of DashboardDefinitionsGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The DashboardDefinitions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Azure Managed Dashboard. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public DashboardDefinitionsGetAllCollectionResultOfT(DashboardDefinitions client, string subscriptionId, string resourceGroupName, string dashboardName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _dashboardName = dashboardName; + _context = context; + } + + /// Gets the pages of DashboardDefinitionsGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of DashboardDefinitionsGetAllCollectionResultOfT 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; + } + DashboardDefinitionListResponse result = DashboardDefinitionListResponse.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _dashboardName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _dashboardName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DashboardDefinitionCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/IntegrationFabricsGetAllAsyncCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/IntegrationFabricsGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..c50a305dffbf --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/IntegrationFabricsGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class IntegrationFabricsGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly IntegrationFabrics _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of IntegrationFabricsGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The IntegrationFabrics client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The workspace name of Azure Managed Grafana. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public IntegrationFabricsGetAllAsyncCollectionResultOfT(IntegrationFabrics client, string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of IntegrationFabricsGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of IntegrationFabricsGetAllAsyncCollectionResultOfT 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; + } + IntegrationFabricListResponse result = IntegrationFabricListResponse.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/IntegrationFabricsGetAllCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/IntegrationFabricsGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..ff7bf781a618 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/IntegrationFabricsGetAllCollectionResultOfT.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class IntegrationFabricsGetAllCollectionResultOfT : Pageable + { + private readonly IntegrationFabrics _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of IntegrationFabricsGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The IntegrationFabrics client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The workspace name of Azure Managed Grafana. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public IntegrationFabricsGetAllCollectionResultOfT(IntegrationFabrics client, string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of IntegrationFabricsGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of IntegrationFabricsGetAllCollectionResultOfT 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; + } + IntegrationFabricListResponse result = IntegrationFabricListResponse.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedDashboardsGetAllAsyncCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedDashboardsGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..12e83c349f57 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedDashboardsGetAllAsyncCollectionResultOfT.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.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class ManagedDashboardsGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly ManagedDashboards _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of ManagedDashboardsGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ManagedDashboards client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ManagedDashboardsGetAllAsyncCollectionResultOfT(ManagedDashboards client, string subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of ManagedDashboardsGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ManagedDashboardsGetAllAsyncCollectionResultOfT 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; + } + ManagedDashboardListResponse result = ManagedDashboardListResponse.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ManagedDashboardCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedDashboardsGetAllCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedDashboardsGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..9d5aa750713a --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedDashboardsGetAllCollectionResultOfT.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.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class ManagedDashboardsGetAllCollectionResultOfT : Pageable + { + private readonly ManagedDashboards _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of ManagedDashboardsGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ManagedDashboards client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ManagedDashboardsGetAllCollectionResultOfT(ManagedDashboards client, string subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of ManagedDashboardsGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ManagedDashboardsGetAllCollectionResultOfT 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; + } + ManagedDashboardListResponse result = ManagedDashboardListResponse.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ManagedDashboardCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedDashboardsGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedDashboardsGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..b0e194f52ecb --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedDashboardsGetBySubscriptionAsyncCollectionResultOfT.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class ManagedDashboardsGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly ManagedDashboards _client; + private readonly string _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of ManagedDashboardsGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ManagedDashboards client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ManagedDashboardsGetBySubscriptionAsyncCollectionResultOfT(ManagedDashboards client, string subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of ManagedDashboardsGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ManagedDashboardsGetBySubscriptionAsyncCollectionResultOfT 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; + } + ManagedDashboardListResponse result = ManagedDashboardListResponse.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.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableGrafanaSubscriptionResource.GetManagedDashboards"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedDashboardsGetBySubscriptionCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedDashboardsGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..a9a1f516b238 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedDashboardsGetBySubscriptionCollectionResultOfT.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class ManagedDashboardsGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly ManagedDashboards _client; + private readonly string _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of ManagedDashboardsGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ManagedDashboards client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ManagedDashboardsGetBySubscriptionCollectionResultOfT(ManagedDashboards client, string subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of ManagedDashboardsGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ManagedDashboardsGetBySubscriptionCollectionResultOfT 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; + } + ManagedDashboardListResponse result = ManagedDashboardListResponse.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.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableGrafanaSubscriptionResource.GetManagedDashboards"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedGrafanasGetAllAsyncCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedGrafanasGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..54558ebb45aa --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedGrafanasGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class ManagedGrafanasGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly ManagedGrafanas _client; + private readonly string _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of ManagedGrafanasGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ManagedGrafanas client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ManagedGrafanasGetAllAsyncCollectionResultOfT(ManagedGrafanas client, string subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of ManagedGrafanasGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ManagedGrafanasGetAllAsyncCollectionResultOfT 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; + } + ManagedGrafanaListResponse result = ManagedGrafanaListResponse.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _context) : _client.CreateGetAllRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableGrafanaSubscriptionResource.GetManagedGrafanas"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedGrafanasGetAllCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedGrafanasGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..fedc937199ef --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedGrafanasGetAllCollectionResultOfT.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class ManagedGrafanasGetAllCollectionResultOfT : Pageable + { + private readonly ManagedGrafanas _client; + private readonly string _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of ManagedGrafanasGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ManagedGrafanas client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ManagedGrafanasGetAllCollectionResultOfT(ManagedGrafanas client, string subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of ManagedGrafanasGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ManagedGrafanasGetAllCollectionResultOfT 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; + } + ManagedGrafanaListResponse result = ManagedGrafanaListResponse.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _context) : _client.CreateGetAllRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableGrafanaSubscriptionResource.GetManagedGrafanas"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedGrafanasGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedGrafanasGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..441c3f348b56 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedGrafanasGetByResourceGroupAsyncCollectionResultOfT.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.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class ManagedGrafanasGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly ManagedGrafanas _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of ManagedGrafanasGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ManagedGrafanas client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ManagedGrafanasGetByResourceGroupAsyncCollectionResultOfT(ManagedGrafanas client, string subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of ManagedGrafanasGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ManagedGrafanasGetByResourceGroupAsyncCollectionResultOfT 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; + } + ManagedGrafanaListResponse result = ManagedGrafanaListResponse.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.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ManagedGrafanaCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedGrafanasGetByResourceGroupCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedGrafanasGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..abd8ecb3c4cb --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedGrafanasGetByResourceGroupCollectionResultOfT.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.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class ManagedGrafanasGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly ManagedGrafanas _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of ManagedGrafanasGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ManagedGrafanas client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ManagedGrafanasGetByResourceGroupCollectionResultOfT(ManagedGrafanas client, string subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of ManagedGrafanasGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ManagedGrafanasGetByResourceGroupCollectionResultOfT 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; + } + ManagedGrafanaListResponse result = ManagedGrafanaListResponse.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.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ManagedGrafanaCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedPrivateEndpointModelsGetAllAsyncCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedPrivateEndpointModelsGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..8f97d06cca24 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedPrivateEndpointModelsGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class ManagedPrivateEndpointModelsGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly ManagedPrivateEndpointModels _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of ManagedPrivateEndpointModelsGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ManagedPrivateEndpointModels client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The workspace name of Azure Managed Grafana. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ManagedPrivateEndpointModelsGetAllAsyncCollectionResultOfT(ManagedPrivateEndpointModels client, string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of ManagedPrivateEndpointModelsGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ManagedPrivateEndpointModelsGetAllAsyncCollectionResultOfT 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; + } + ManagedPrivateEndpointModelListResponse result = ManagedPrivateEndpointModelListResponse.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedPrivateEndpointModelsGetAllCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedPrivateEndpointModelsGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..681197885d95 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/ManagedPrivateEndpointModelsGetAllCollectionResultOfT.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class ManagedPrivateEndpointModelsGetAllCollectionResultOfT : Pageable + { + private readonly ManagedPrivateEndpointModels _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of ManagedPrivateEndpointModelsGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ManagedPrivateEndpointModels client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The workspace name of Azure Managed Grafana. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ManagedPrivateEndpointModelsGetAllCollectionResultOfT(ManagedPrivateEndpointModels client, string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of ManagedPrivateEndpointModelsGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ManagedPrivateEndpointModelsGetAllCollectionResultOfT 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; + } + ManagedPrivateEndpointModelListResponse result = ManagedPrivateEndpointModelListResponse.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/PrivateEndpointConnectionsGetAllAsyncCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/PrivateEndpointConnectionsGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..2a7231688b93 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/PrivateEndpointConnectionsGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class PrivateEndpointConnectionsGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly PrivateEndpointConnections _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of PrivateEndpointConnectionsGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The PrivateEndpointConnections client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The workspace name of Azure Managed Grafana. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public PrivateEndpointConnectionsGetAllAsyncCollectionResultOfT(PrivateEndpointConnections client, string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of PrivateEndpointConnectionsGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of PrivateEndpointConnectionsGetAllAsyncCollectionResultOfT 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; + } + GrafanaPrivateEndpointConnectionListResult result = GrafanaPrivateEndpointConnectionListResult.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/PrivateEndpointConnectionsGetAllCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/PrivateEndpointConnectionsGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..5dcde2c7e46f --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/PrivateEndpointConnectionsGetAllCollectionResultOfT.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class PrivateEndpointConnectionsGetAllCollectionResultOfT : Pageable + { + private readonly PrivateEndpointConnections _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of PrivateEndpointConnectionsGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The PrivateEndpointConnections client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The workspace name of Azure Managed Grafana. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public PrivateEndpointConnectionsGetAllCollectionResultOfT(PrivateEndpointConnections client, string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of PrivateEndpointConnectionsGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of PrivateEndpointConnectionsGetAllCollectionResultOfT 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; + } + GrafanaPrivateEndpointConnectionListResult result = GrafanaPrivateEndpointConnectionListResult.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/PrivateLinkResourcesGetAllAsyncCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/PrivateLinkResourcesGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..fa9a8c5ca950 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/PrivateLinkResourcesGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class PrivateLinkResourcesGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly PrivateLinkResources _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of PrivateLinkResourcesGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The PrivateLinkResources client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The workspace name of Azure Managed Grafana. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public PrivateLinkResourcesGetAllAsyncCollectionResultOfT(PrivateLinkResources client, string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of PrivateLinkResourcesGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of PrivateLinkResourcesGetAllAsyncCollectionResultOfT 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; + } + GrafanaPrivateLinkResourceListResult result = GrafanaPrivateLinkResourceListResult.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/PrivateLinkResourcesGetAllCollectionResultOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/PrivateLinkResourcesGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..efe4339fa549 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/CollectionResults/PrivateLinkResourcesGetAllCollectionResultOfT.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Grafana.Models; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class PrivateLinkResourcesGetAllCollectionResultOfT : Pageable + { + private readonly PrivateLinkResources _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of PrivateLinkResourcesGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The PrivateLinkResources client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The workspace name of Azure Managed Grafana. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public PrivateLinkResourcesGetAllCollectionResultOfT(PrivateLinkResources client, string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of PrivateLinkResourcesGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of PrivateLinkResourcesGetAllCollectionResultOfT 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; + } + GrafanaPrivateLinkResourceListResult result = GrafanaPrivateLinkResourceListResult.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionCollection.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionCollection.cs new file mode 100644 index 000000000000..ea1c870bc19b --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionCollection.cs @@ -0,0 +1,573 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Grafana +{ + /// + /// 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 GetDashboardDefinitions method from an instance of . + /// + public partial class DashboardDefinitionCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _dashboardDefinitionsClientDiagnostics; + private readonly DashboardDefinitions _dashboardDefinitionsRestClient; + + /// Initializes a new instance of DashboardDefinitionCollection for mocking. + protected DashboardDefinitionCollection() + { + } + + /// 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 DashboardDefinitionCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(DashboardDefinitionResource.ResourceType, out string dashboardDefinitionApiVersion); + _dashboardDefinitionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", DashboardDefinitionResource.ResourceType.Namespace, Diagnostics); + _dashboardDefinitionsRestClient = new DashboardDefinitions(_dashboardDefinitionsClientDiagnostics, Pipeline, Endpoint, dashboardDefinitionApiVersion ?? "2025-09-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ManagedDashboardResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ManagedDashboardResource.ResourceType), id); + } + } + + /// + /// Create a dashboard definition to update dashboard resource. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Create. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Dashboard Definition. + /// The dashboard definition resource to create or update. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string definitionName, DashboardDefinitionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(definitionName, nameof(definitionName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, definitionName, DashboardDefinitionData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DashboardDefinitionData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + GrafanaArmOperation operation = new GrafanaArmOperation(Response.FromValue(new DashboardDefinitionResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a dashboard definition to update dashboard resource. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Create. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Dashboard Definition. + /// The dashboard definition resource to create or update. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string definitionName, DashboardDefinitionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(definitionName, nameof(definitionName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, definitionName, DashboardDefinitionData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DashboardDefinitionData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + GrafanaArmOperation operation = new GrafanaArmOperation(Response.FromValue(new DashboardDefinitionResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the properties of a specific dashboard definition. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Get. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// + /// The name of the Dashboard Definition. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string definitionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(definitionName, nameof(definitionName)); + + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, definitionName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DashboardDefinitionData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new DashboardDefinitionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the properties of a specific dashboard definition. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Get. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// + /// The name of the Dashboard Definition. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string definitionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(definitionName, nameof(definitionName)); + + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, definitionName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DashboardDefinitionData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new DashboardDefinitionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List all dashboard definitions under the specified dashboard. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions. + /// + /// + /// Operation Id. + /// DashboardDefinitions_List. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new DashboardDefinitionsGetAllAsyncCollectionResultOfT(_dashboardDefinitionsRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new DashboardDefinitionResource(Client, data)); + } + + /// + /// List all dashboard definitions under the specified dashboard. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions. + /// + /// + /// Operation Id. + /// DashboardDefinitions_List. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new DashboardDefinitionsGetAllCollectionResultOfT(_dashboardDefinitionsRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new DashboardDefinitionResource(Client, data)); + } + + /// + /// Get the properties of a specific dashboard definition. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Get. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// + /// The name of the Dashboard Definition. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string definitionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(definitionName, nameof(definitionName)); + + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, definitionName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DashboardDefinitionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DashboardDefinitionData)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 properties of a specific dashboard definition. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Get. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// + /// The name of the Dashboard Definition. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string definitionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(definitionName, nameof(definitionName)); + + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, definitionName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DashboardDefinitionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DashboardDefinitionData)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 properties of a specific dashboard definition. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Get. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// + /// The name of the Dashboard Definition. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string definitionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(definitionName, nameof(definitionName)); + + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, definitionName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DashboardDefinitionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DashboardDefinitionData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new DashboardDefinitionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the properties of a specific dashboard definition. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Get. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// + /// The name of the Dashboard Definition. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string definitionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(definitionName, nameof(definitionName)); + + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, definitionName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DashboardDefinitionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DashboardDefinitionData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new DashboardDefinitionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + /// The cancellation token to use. + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionData.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionData.Serialization.cs new file mode 100644 index 000000000000..2dc2b3950247 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionData.Serialization.cs @@ -0,0 +1,192 @@ +// 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.Grafana.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Grafana +{ + /// The dashboard definition resource type. + public partial class DashboardDefinitionData : 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(DashboardDefinitionData)} 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. + DashboardDefinitionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DashboardDefinitionData)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(DashboardDefinitionData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDashboardDefinitionData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DashboardDefinitionData DeserializeDashboardDefinitionData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + DashboardDefinitionProperties properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = 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, AzureResourceManagerGrafanaContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = DashboardDefinitionProperties.DeserializeDashboardDefinitionProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DashboardDefinitionData( + 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, AzureResourceManagerGrafanaContext.Default); + default: + throw new FormatException($"The model {nameof(DashboardDefinitionData)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + DashboardDefinitionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DashboardDefinitionData)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 DeserializeDashboardDefinitionData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DashboardDefinitionData)} 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(DashboardDefinitionData dashboardDefinitionData) + { + if (dashboardDefinitionData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(dashboardDefinitionData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static DashboardDefinitionData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDashboardDefinitionData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionData.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionData.cs new file mode 100644 index 000000000000..be546127e2bb --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionData.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Grafana.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Grafana +{ + /// The dashboard definition resource type. + public partial class DashboardDefinitionData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public DashboardDefinitionData() + { + } + + /// 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. + /// Properties specific to the dashboard definition resource. + internal DashboardDefinitionData(string id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, DashboardDefinitionProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// Properties specific to the dashboard definition resource. + public DashboardDefinitionProperties Properties { get; set; } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionResource.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionResource.Serialization.cs new file mode 100644 index 000000000000..bdd381127b3a --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionResource.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.Grafana +{ + /// + public partial class DashboardDefinitionResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new DashboardDefinitionData(); + + /// 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. + DashboardDefinitionData 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, AzureResourceManagerGrafanaContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + DashboardDefinitionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerGrafanaContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionResource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionResource.cs new file mode 100644 index 000000000000..26bf8cdfb039 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/DashboardDefinitionResource.cs @@ -0,0 +1,404 @@ +// 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.Grafana +{ + /// + /// A class representing a DashboardDefinition 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 GetDashboardDefinitions method. + /// + public partial class DashboardDefinitionResource : ArmResource + { + private readonly ClientDiagnostics _dashboardDefinitionsClientDiagnostics; + private readonly DashboardDefinitions _dashboardDefinitionsRestClient; + private readonly DashboardDefinitionData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Dashboard/dashboards/dashboardDefinitions"; + + /// Initializes a new instance of DashboardDefinitionResource for mocking. + protected DashboardDefinitionResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal DashboardDefinitionResource(ArmClient client, DashboardDefinitionData 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 DashboardDefinitionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string dashboardDefinitionApiVersion); + _dashboardDefinitionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ResourceType.Namespace, Diagnostics); + _dashboardDefinitionsRestClient = new DashboardDefinitions(_dashboardDefinitionsClientDiagnostics, Pipeline, Endpoint, dashboardDefinitionApiVersion ?? "2025-09-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 DashboardDefinitionData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The dashboardName. + /// The definitionName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string dashboardName, string definitionName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}"; + 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 properties of a specific dashboard definition. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Get. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DashboardDefinitionData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new DashboardDefinitionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the properties of a specific dashboard definition. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Get. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DashboardDefinitionData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new DashboardDefinitionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a dashboard definition. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Delete. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + GrafanaArmOperation operation = new GrafanaArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a dashboard definition. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Delete. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + GrafanaArmOperation operation = new GrafanaArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a dashboard definition to update dashboard resource. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Create. + /// + /// + /// Default Api Version. + /// 2025-09-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 dashboard definition resource to create or update. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, DashboardDefinitionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, DashboardDefinitionData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DashboardDefinitionData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + GrafanaArmOperation operation = new GrafanaArmOperation(Response.FromValue(new DashboardDefinitionResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a dashboard definition to update dashboard resource. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}/dashboardDefinitions/{definitionName}. + /// + /// + /// Operation Id. + /// DashboardDefinitions_Create. + /// + /// + /// Default Api Version. + /// 2025-09-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 dashboard definition resource to create or update. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, DashboardDefinitionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _dashboardDefinitionsClientDiagnostics.CreateScope("DashboardDefinitionResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dashboardDefinitionsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, DashboardDefinitionData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DashboardDefinitionData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + GrafanaArmOperation operation = new GrafanaArmOperation(Response.FromValue(new DashboardDefinitionResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/GrafanaExtensions.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/GrafanaExtensions.cs index 72abbcb0ed3e..1a29b8039964 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/GrafanaExtensions.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/GrafanaExtensions.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.Grafana.Mocking; using Azure.ResourceManager.Resources; @@ -17,30 +19,32 @@ namespace Azure.ResourceManager.Grafana /// A class to add extension methods to Azure.ResourceManager.Grafana. public static partial class GrafanaExtensions { + /// private static MockableGrafanaArmClient GetMockableGrafanaArmClient(ArmClient client) { - return client.GetCachedClient(client0 => new MockableGrafanaArmClient(client0)); + return client.GetCachedClient(client0 => new MockableGrafanaArmClient(client0, ResourceIdentifier.Root)); } - private static MockableGrafanaResourceGroupResource GetMockableGrafanaResourceGroupResource(ArmResource resource) + /// + private static MockableGrafanaResourceGroupResource GetMockableGrafanaResourceGroupResource(ResourceGroupResource resourceGroupResource) { - return resource.GetCachedClient(client => new MockableGrafanaResourceGroupResource(client, resource.Id)); + return resourceGroupResource.GetCachedClient(client => new MockableGrafanaResourceGroupResource(client, resourceGroupResource.Id)); } - private static MockableGrafanaSubscriptionResource GetMockableGrafanaSubscriptionResource(ArmResource resource) + /// + private static MockableGrafanaSubscriptionResource GetMockableGrafanaSubscriptionResource(SubscriptionResource subscriptionResource) { - return resource.GetCachedClient(client => new MockableGrafanaSubscriptionResource(client, resource.Id)); + return subscriptionResource.GetCachedClient(client => new MockableGrafanaSubscriptionResource(client, subscriptionResource.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 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. @@ -52,14 +56,13 @@ public static ManagedGrafanaResource GetManagedGrafanaResource(this ArmClient cl } /// - /// 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. @@ -71,14 +74,13 @@ public static GrafanaPrivateEndpointConnectionResource GetGrafanaPrivateEndpoint } /// - /// 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. @@ -90,14 +92,13 @@ public static GrafanaPrivateLinkResource GetGrafanaPrivateLinkResource(this ArmC } /// - /// 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. @@ -109,14 +110,13 @@ public static ManagedPrivateEndpointModelResource GetManagedPrivateEndpointModel } /// - /// 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. @@ -128,14 +128,13 @@ public static GrafanaIntegrationFabricResource GetGrafanaIntegrationFabricResour } /// - /// 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. @@ -147,15 +146,33 @@ public static ManagedDashboardResource GetManagedDashboardResource(this ArmClien } /// - /// Gets a collection of ManagedGrafanaResources in the ResourceGroupResource. + /// 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 DashboardDefinitionResource GetDashboardDefinitionResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableGrafanaArmClient(client).GetDashboardDefinitionResource(id); + } + + /// + /// Gets a collection of ManagedGrafanas in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. /// is null. - /// An object representing collection of ManagedGrafanaResources and their operations over a ManagedGrafanaResource. + /// An object representing collection of ManagedGrafanas and their operations over a ManagedGrafanaResource. public static ManagedGrafanaCollection GetManagedGrafanas(this ResourceGroupResource resourceGroupResource) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -165,34 +182,15 @@ public static ManagedGrafanaCollection GetManagedGrafanas(this ResourceGroupReso /// /// Get the properties of a specific workspace for Grafana resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// /// - /// Operation Id - /// ManagedGrafana_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// 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 the method will execute against. /// The workspace name of Azure Managed Grafana. /// 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> GetManagedGrafanaAsync(this ResourceGroupResource resourceGroupResource, string workspaceName, CancellationToken cancellationToken = default) { @@ -203,34 +201,15 @@ public static async Task> GetManagedGrafanaAsyn /// /// Get the properties of a specific workspace for Grafana resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// 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 the method will execute against. /// The workspace name of Azure Managed Grafana. /// 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 GetManagedGrafana(this ResourceGroupResource resourceGroupResource, string workspaceName, CancellationToken cancellationToken = default) { @@ -240,15 +219,15 @@ public static Response GetManagedGrafana(this ResourceGr } /// - /// Gets a collection of ManagedDashboardResources in the ResourceGroupResource. + /// Gets a collection of ManagedDashboards in the /// - /// 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. /// is null. - /// An object representing collection of ManagedDashboardResources and their operations over a ManagedDashboardResource. + /// An object representing collection of ManagedDashboards and their operations over a ManagedDashboardResource. public static ManagedDashboardCollection GetManagedDashboards(this ResourceGroupResource resourceGroupResource) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -258,34 +237,15 @@ public static ManagedDashboardCollection GetManagedDashboards(this ResourceGroup /// /// Get the properties of a specific dashboard for grafana resource. - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// 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 the method will execute against. /// The name of the Azure Managed Dashboard. /// 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> GetManagedDashboardAsync(this ResourceGroupResource resourceGroupResource, string dashboardName, CancellationToken cancellationToken = default) { @@ -296,34 +256,15 @@ public static async Task> GetManagedDashboard /// /// Get the properties of a specific dashboard for grafana resource. - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// 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 the method will execute against. /// The name of the Azure Managed Dashboard. /// 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 GetManagedDashboard(this ResourceGroupResource resourceGroupResource, string dashboardName, CancellationToken cancellationToken = default) { @@ -333,34 +274,58 @@ public static Response GetManagedDashboard(this Resour } /// - /// List all resources of workspaces for Grafana under the specified subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/grafana - /// + /// Manual approve private endpoint connection /// - /// Operation Id - /// ManagedGrafana_List - /// - /// - /// Default Api Version - /// 2025-08-01 + /// Mocking. + /// To mock this method, please mock instead. /// + /// + /// The the method will execute against. + /// 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 workspace name of Azure Managed Grafana. + /// The private endpoint connection name of Azure Managed Grafana. + /// + /// The cancellation token to use. + /// is null. + public static async Task> ApproveAsync(this ResourceGroupResource resourceGroupResource, WaitUntil waitUntil, string workspaceName, string privateEndpointConnectionName, GrafanaPrivateEndpointConnectionData data = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableGrafanaResourceGroupResource(resourceGroupResource).ApproveAsync(waitUntil, workspaceName, privateEndpointConnectionName, data, cancellationToken).ConfigureAwait(false); + } + + /// + /// Manual approve private endpoint connection /// - /// Resource - /// + /// Mocking. + /// To mock this method, please mock instead. /// - /// + /// + /// The the method will execute against. + /// 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 workspace name of Azure Managed Grafana. + /// The private endpoint connection name of Azure Managed Grafana. + /// + /// The cancellation token to use. + /// is null. + public static ArmOperation Approve(this ResourceGroupResource resourceGroupResource, WaitUntil waitUntil, string workspaceName, string privateEndpointConnectionName, GrafanaPrivateEndpointConnectionData data = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableGrafanaResourceGroupResource(resourceGroupResource).Approve(waitUntil, workspaceName, privateEndpointConnectionName, data, cancellationToken); + } + + /// + /// List all resources of workspaces for Grafana under the specified subscription. /// - /// 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 cancellation token to use. /// is null. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public static AsyncPageable GetManagedGrafanasAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -370,30 +335,12 @@ public static AsyncPageable GetManagedGrafanasAsync(this /// /// List all resources of workspaces for Grafana under the specified subscription. - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/grafana - /// - /// - /// Operation Id - /// ManagedGrafana_List - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// 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 the method will execute against. /// The cancellation token to use. /// is null. /// A collection of that may take multiple service requests to iterate over. @@ -406,33 +353,15 @@ public static Pageable GetManagedGrafanas(this Subscript /// /// List all resources of dashboards under the specified subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/dashboards - /// - /// - /// Operation Id - /// ManagedDashboard_ListBySubscription - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// 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 the method will execute against. /// The cancellation token to use. /// is null. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public static AsyncPageable GetManagedDashboardsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -442,30 +371,12 @@ public static AsyncPageable GetManagedDashboardsAsync( /// /// List all resources of dashboards under the specified subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/dashboards - /// - /// - /// Operation Id - /// ManagedDashboard_ListBySubscription - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// 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 the method will execute against. /// The cancellation token to use. /// is null. /// A collection of that may take multiple service requests to iterate over. diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/MockableGrafanaArmClient.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/MockableGrafanaArmClient.cs index 9ca0de85722f..20ce023a3e55 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/MockableGrafanaArmClient.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/MockableGrafanaArmClient.cs @@ -6,38 +6,27 @@ #nullable disable using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Mocking { - /// A class to add extension methods to ArmClient. + /// A class to add extension methods to . public partial class MockableGrafanaArmClient : ArmResource { - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableGrafanaArmClient for mocking. protected MockableGrafanaArmClient() { } - /// 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 MockableGrafanaArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) { } - internal MockableGrafanaArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// - /// 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 ManagedGrafanaResource GetManagedGrafanaResource(ResourceIdentifier id) @@ -46,10 +35,7 @@ public virtual ManagedGrafanaResource GetManagedGrafanaResource(ResourceIdentifi return new ManagedGrafanaResource(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. - /// + /// 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 GrafanaPrivateEndpointConnectionResource GetGrafanaPrivateEndpointConnectionResource(ResourceIdentifier id) @@ -58,10 +44,7 @@ public virtual GrafanaPrivateEndpointConnectionResource GetGrafanaPrivateEndpoin return new GrafanaPrivateEndpointConnectionResource(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. - /// + /// 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 GrafanaPrivateLinkResource GetGrafanaPrivateLinkResource(ResourceIdentifier id) @@ -70,10 +53,7 @@ public virtual GrafanaPrivateLinkResource GetGrafanaPrivateLinkResource(Resource return new GrafanaPrivateLinkResource(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. - /// + /// 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 ManagedPrivateEndpointModelResource GetManagedPrivateEndpointModelResource(ResourceIdentifier id) @@ -82,10 +62,7 @@ public virtual ManagedPrivateEndpointModelResource GetManagedPrivateEndpointMode return new ManagedPrivateEndpointModelResource(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. - /// + /// 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 GrafanaIntegrationFabricResource GetGrafanaIntegrationFabricResource(ResourceIdentifier id) @@ -94,10 +71,7 @@ public virtual GrafanaIntegrationFabricResource GetGrafanaIntegrationFabricResou return new GrafanaIntegrationFabricResource(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. - /// + /// 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 ManagedDashboardResource GetManagedDashboardResource(ResourceIdentifier id) @@ -105,5 +79,14 @@ public virtual ManagedDashboardResource GetManagedDashboardResource(ResourceIden ManagedDashboardResource.ValidateResourceId(id); return new ManagedDashboardResource(Client, id); } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual DashboardDefinitionResource GetDashboardDefinitionResource(ResourceIdentifier id) + { + DashboardDefinitionResource.ValidateResourceId(id); + return new DashboardDefinitionResource(Client, id); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/MockableGrafanaResourceGroupResource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/MockableGrafanaResourceGroupResource.cs index eb5a78fe3476..6750d26a2fde 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/MockableGrafanaResourceGroupResource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/MockableGrafanaResourceGroupResource.cs @@ -8,33 +8,39 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Grafana; +using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.Grafana.Mocking { - /// A class to add extension methods to ResourceGroupResource. + /// A class to add extension methods to . public partial class MockableGrafanaResourceGroupResource : ArmResource { - /// Initializes a new instance of the class for mocking. + private ClientDiagnostics _privateEndpointConnectionsClientDiagnostics; + private PrivateEndpointConnections _privateEndpointConnectionsRestClient; + + /// Initializes a new instance of MockableGrafanaResourceGroupResource for mocking. protected MockableGrafanaResourceGroupResource() { } - /// 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 MockableGrafanaResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } + private ClientDiagnostics PrivateEndpointConnectionsClientDiagnostics => _privateEndpointConnectionsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Grafana.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - /// Gets a collection of ManagedGrafanaResources in the ResourceGroupResource. - /// An object representing collection of ManagedGrafanaResources and their operations over a ManagedGrafanaResource. + private PrivateEndpointConnections PrivateEndpointConnectionsRestClient => _privateEndpointConnectionsRestClient ??= new PrivateEndpointConnections(PrivateEndpointConnectionsClientDiagnostics, Pipeline, Endpoint, "2025-09-01-preview"); + + /// Gets a collection of ManagedGrafanas in the . + /// An object representing collection of ManagedGrafanas and their operations over a ManagedGrafanaResource. public virtual ManagedGrafanaCollection GetManagedGrafanas() { return GetCachedClient(client => new ManagedGrafanaCollection(client, Id)); @@ -44,20 +50,16 @@ public virtual ManagedGrafanaCollection GetManagedGrafanas() /// Get the properties of a specific workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedGrafanas_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -68,6 +70,8 @@ public virtual ManagedGrafanaCollection GetManagedGrafanas() [ForwardsClientCalls] public virtual async Task> GetManagedGrafanaAsync(string workspaceName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + return await GetManagedGrafanas().GetAsync(workspaceName, cancellationToken).ConfigureAwait(false); } @@ -75,20 +79,16 @@ public virtual async Task> GetManagedGrafanaAsy /// Get the properties of a specific workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedGrafanas_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -99,11 +99,13 @@ public virtual async Task> GetManagedGrafanaAsy [ForwardsClientCalls] public virtual Response GetManagedGrafana(string workspaceName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + return GetManagedGrafanas().Get(workspaceName, cancellationToken); } - /// Gets a collection of ManagedDashboardResources in the ResourceGroupResource. - /// An object representing collection of ManagedDashboardResources and their operations over a ManagedDashboardResource. + /// Gets a collection of ManagedDashboards in the . + /// An object representing collection of ManagedDashboards and their operations over a ManagedDashboardResource. public virtual ManagedDashboardCollection GetManagedDashboards() { return GetCachedClient(client => new ManagedDashboardCollection(client, Id)); @@ -113,20 +115,16 @@ public virtual ManagedDashboardCollection GetManagedDashboards() /// Get the properties of a specific dashboard for grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedDashboards_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -137,6 +135,8 @@ public virtual ManagedDashboardCollection GetManagedDashboards() [ForwardsClientCalls] public virtual async Task> GetManagedDashboardAsync(string dashboardName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); + return await GetManagedDashboards().GetAsync(dashboardName, cancellationToken).ConfigureAwait(false); } @@ -144,20 +144,16 @@ public virtual async Task> GetManagedDashboar /// Get the properties of a specific dashboard for grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedDashboards_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -168,7 +164,127 @@ public virtual async Task> GetManagedDashboar [ForwardsClientCalls] public virtual Response GetManagedDashboard(string dashboardName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); + return GetManagedDashboards().Get(dashboardName, cancellationToken); } + + /// + /// Manual approve private endpoint connection + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// PrivateEndpointConnections_Approve. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The workspace name of Azure Managed Grafana. + /// The private endpoint connection name of Azure Managed Grafana. + /// + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> ApproveAsync(WaitUntil waitUntil, string workspaceName, string privateEndpointConnectionName, GrafanaPrivateEndpointConnectionData data = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = PrivateEndpointConnectionsClientDiagnostics.CreateScope("MockableGrafanaResourceGroupResource.Approve"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = PrivateEndpointConnectionsRestClient.CreateApproveRequest(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, privateEndpointConnectionName, GrafanaPrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + GrafanaArmOperation operation = new GrafanaArmOperation( + new GrafanaPrivateEndpointConnectionOperationSource(Client), + PrivateEndpointConnectionsClientDiagnostics, + 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; + } + } + + /// + /// Manual approve private endpoint connection + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// PrivateEndpointConnections_Approve. + /// + /// + /// Default Api Version. + /// 2025-09-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The workspace name of Azure Managed Grafana. + /// The private endpoint connection name of Azure Managed Grafana. + /// + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual ArmOperation Approve(WaitUntil waitUntil, string workspaceName, string privateEndpointConnectionName, GrafanaPrivateEndpointConnectionData data = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = PrivateEndpointConnectionsClientDiagnostics.CreateScope("MockableGrafanaResourceGroupResource.Approve"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = PrivateEndpointConnectionsRestClient.CreateApproveRequest(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, privateEndpointConnectionName, GrafanaPrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + GrafanaArmOperation operation = new GrafanaArmOperation( + new GrafanaPrivateEndpointConnectionOperationSource(Client), + PrivateEndpointConnectionsClientDiagnostics, + 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/MockableGrafanaSubscriptionResource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/MockableGrafanaSubscriptionResource.cs index 82da93d7eedc..538c76119c53 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/MockableGrafanaSubscriptionResource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Extensions/MockableGrafanaSubscriptionResource.cs @@ -6,91 +6,85 @@ #nullable disable using System.Threading; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Grafana; +using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.Grafana.Mocking { - /// A class to add extension methods to SubscriptionResource. + /// A class to add extension methods to . public partial class MockableGrafanaSubscriptionResource : ArmResource { - private ClientDiagnostics _managedGrafanaClientDiagnostics; - private ManagedGrafanasRestOperations _managedGrafanaRestClient; - private ClientDiagnostics _managedDashboardClientDiagnostics; - private ManagedDashboardsRestOperations _managedDashboardRestClient; + private ClientDiagnostics _managedGrafanasClientDiagnostics; + private ManagedGrafanas _managedGrafanasRestClient; + private ClientDiagnostics _managedDashboardsClientDiagnostics; + private ManagedDashboards _managedDashboardsRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableGrafanaSubscriptionResource for mocking. protected MockableGrafanaSubscriptionResource() { } - /// 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 MockableGrafanaSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private ClientDiagnostics ManagedGrafanaClientDiagnostics => _managedGrafanaClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Grafana", ManagedGrafanaResource.ResourceType.Namespace, Diagnostics); - private ManagedGrafanasRestOperations ManagedGrafanaRestClient => _managedGrafanaRestClient ??= new ManagedGrafanasRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(ManagedGrafanaResource.ResourceType)); - private ClientDiagnostics ManagedDashboardClientDiagnostics => _managedDashboardClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Grafana", ManagedDashboardResource.ResourceType.Namespace, Diagnostics); - private ManagedDashboardsRestOperations ManagedDashboardRestClient => _managedDashboardRestClient ??= new ManagedDashboardsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(ManagedDashboardResource.ResourceType)); + private ClientDiagnostics ManagedGrafanasClientDiagnostics => _managedGrafanasClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Grafana.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } + private ManagedGrafanas ManagedGrafanasRestClient => _managedGrafanasRestClient ??= new ManagedGrafanas(ManagedGrafanasClientDiagnostics, Pipeline, Endpoint, "2025-09-01-preview"); + + private ClientDiagnostics ManagedDashboardsClientDiagnostics => _managedDashboardsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Grafana.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private ManagedDashboards ManagedDashboardsRestClient => _managedDashboardsRestClient ??= new ManagedDashboards(ManagedDashboardsClientDiagnostics, Pipeline, Endpoint, "2025-09-01-preview"); /// /// List all resources of workspaces for Grafana under the specified subscription. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/grafana + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/grafana. /// /// - /// Operation Id - /// ManagedGrafana_List + /// Operation Id. + /// ManagedGrafanas_List. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetManagedGrafanasAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => ManagedGrafanaRestClient.CreateListRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ManagedGrafanaRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ManagedGrafanaResource(Client, ManagedGrafanaData.DeserializeManagedGrafanaData(e)), ManagedGrafanaClientDiagnostics, Pipeline, "MockableGrafanaSubscriptionResource.GetManagedGrafanas", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new ManagedGrafanasGetAllAsyncCollectionResultOfT(ManagedGrafanasRestClient, Id.SubscriptionId, context), data => new ManagedGrafanaResource(Client, data)); } /// /// List all resources of workspaces for Grafana under the specified subscription. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/grafana + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/grafana. /// /// - /// Operation Id - /// ManagedGrafana_List + /// Operation Id. + /// ManagedGrafanas_List. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -98,59 +92,55 @@ public virtual AsyncPageable GetManagedGrafanasAsync(Can /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetManagedGrafanas(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => ManagedGrafanaRestClient.CreateListRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ManagedGrafanaRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ManagedGrafanaResource(Client, ManagedGrafanaData.DeserializeManagedGrafanaData(e)), ManagedGrafanaClientDiagnostics, Pipeline, "MockableGrafanaSubscriptionResource.GetManagedGrafanas", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new ManagedGrafanasGetAllCollectionResultOfT(ManagedGrafanasRestClient, Id.SubscriptionId, context), data => new ManagedGrafanaResource(Client, data)); } /// /// List all resources of dashboards under the specified subscription. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/dashboards - /// - /// - /// Operation Id - /// ManagedDashboard_ListBySubscription + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/dashboards. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedDashboards_ListBySubscription. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetManagedDashboardsAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => ManagedDashboardRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ManagedDashboardRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ManagedDashboardResource(Client, ManagedDashboardData.DeserializeManagedDashboardData(e)), ManagedDashboardClientDiagnostics, Pipeline, "MockableGrafanaSubscriptionResource.GetManagedDashboards", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new ManagedDashboardsGetBySubscriptionAsyncCollectionResultOfT(ManagedDashboardsRestClient, Id.SubscriptionId, context), data => new ManagedDashboardResource(Client, data)); } /// /// List all resources of dashboards under the specified subscription. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/dashboards - /// - /// - /// Operation Id - /// ManagedDashboard_ListBySubscription + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/dashboards. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedDashboards_ListBySubscription. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -158,9 +148,11 @@ public virtual AsyncPageable GetManagedDashboardsAsync /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetManagedDashboards(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => ManagedDashboardRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ManagedDashboardRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ManagedDashboardResource(Client, ManagedDashboardData.DeserializeManagedDashboardData(e)), ManagedDashboardClientDiagnostics, Pipeline, "MockableGrafanaSubscriptionResource.GetManagedDashboards", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new ManagedDashboardsGetBySubscriptionCollectionResultOfT(ManagedDashboardsRestClient, Id.SubscriptionId, context), data => new ManagedDashboardResource(Client, data)); } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricCollection.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricCollection.cs index 5a8a09c3caed..8cd0bae2c1a7 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricCollection.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricCollection.cs @@ -8,12 +8,13 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.Grafana { @@ -24,73 +25,84 @@ namespace Azure.ResourceManager.Grafana /// public partial class GrafanaIntegrationFabricCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics; - private readonly IntegrationFabricsRestOperations _grafanaIntegrationFabricIntegrationFabricsRestClient; + private readonly ClientDiagnostics _integrationFabricsClientDiagnostics; + private readonly IntegrationFabrics _integrationFabricsRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of GrafanaIntegrationFabricCollection for mocking. protected GrafanaIntegrationFabricCollection() { } - /// 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 GrafanaIntegrationFabricCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", GrafanaIntegrationFabricResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(GrafanaIntegrationFabricResource.ResourceType, out string grafanaIntegrationFabricIntegrationFabricsApiVersion); - _grafanaIntegrationFabricIntegrationFabricsRestClient = new IntegrationFabricsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, grafanaIntegrationFabricIntegrationFabricsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(GrafanaIntegrationFabricResource.ResourceType, out string grafanaIntegrationFabricApiVersion); + _integrationFabricsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", GrafanaIntegrationFabricResource.ResourceType.Namespace, Diagnostics); + _integrationFabricsRestClient = new IntegrationFabrics(_integrationFabricsClientDiagnostics, Pipeline, Endpoint, grafanaIntegrationFabricApiVersion ?? "2025-09-01-preview"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ManagedGrafanaResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagedGrafanaResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ManagedGrafanaResource.ResourceType), id); + } } /// /// Create a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} - /// - /// - /// Operation Id - /// IntegrationFabric_Create + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// IntegrationFabrics_Create. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// The integration fabric name of Azure Managed Grafana. - /// The to use. + /// /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string integrationFabricName, GrafanaIntegrationFabricData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.CreateOrUpdate"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _grafanaIntegrationFabricIntegrationFabricsRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, data, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(new GrafanaIntegrationFabricOperationSource(Client), _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics, Pipeline, _grafanaIntegrationFabricIntegrationFabricsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, GrafanaIntegrationFabricData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + GrafanaArmOperation operation = new GrafanaArmOperation( + new GrafanaIntegrationFabricOperationSource(Client), + _integrationFabricsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -104,42 +116,51 @@ public virtual async Task> Create /// Create a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Operation Id - /// IntegrationFabric_Create + /// Operation Id. + /// IntegrationFabrics_Create. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// The integration fabric name of Azure Managed Grafana. - /// The to use. + /// /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string integrationFabricName, GrafanaIntegrationFabricData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.CreateOrUpdate"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.CreateOrUpdate"); scope.Start(); try { - var response = _grafanaIntegrationFabricIntegrationFabricsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, data, cancellationToken); - var operation = new GrafanaArmOperation(new GrafanaIntegrationFabricOperationSource(Client), _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics, Pipeline, _grafanaIntegrationFabricIntegrationFabricsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, GrafanaIntegrationFabricData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + GrafanaArmOperation operation = new GrafanaArmOperation( + new GrafanaIntegrationFabricOperationSource(Client), + _integrationFabricsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -153,38 +174,42 @@ public virtual ArmOperation CreateOrUpdate(Wai /// Get a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} - /// - /// - /// Operation Id - /// IntegrationFabric_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// IntegrationFabrics_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The integration fabric name of Azure Managed Grafana. /// 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 integrationFabricName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.Get"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.Get"); scope.Start(); try { - var response = await _grafanaIntegrationFabricIntegrationFabricsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new GrafanaIntegrationFabricResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -198,38 +223,42 @@ public virtual async Task> GetAsync(s /// Get a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} - /// - /// - /// Operation Id - /// IntegrationFabric_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// IntegrationFabrics_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The integration fabric name of Azure Managed Grafana. /// 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 integrationFabricName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.Get"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.Get"); scope.Start(); try { - var response = _grafanaIntegrationFabricIntegrationFabricsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new GrafanaIntegrationFabricResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -243,50 +272,44 @@ public virtual Response Get(string integration /// List IntegrationFabric resources by ManagedGrafana /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics. /// /// - /// Operation Id - /// IntegrationFabric_List + /// Operation Id. + /// IntegrationFabrics_List. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _grafanaIntegrationFabricIntegrationFabricsRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _grafanaIntegrationFabricIntegrationFabricsRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new GrafanaIntegrationFabricResource(Client, GrafanaIntegrationFabricData.DeserializeGrafanaIntegrationFabricData(e)), _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics, Pipeline, "GrafanaIntegrationFabricCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new IntegrationFabricsGetAllAsyncCollectionResultOfT(_integrationFabricsRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new GrafanaIntegrationFabricResource(Client, data)); } /// /// List IntegrationFabric resources by ManagedGrafana /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics - /// - /// - /// Operation Id - /// IntegrationFabric_List + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// IntegrationFabrics_List. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -294,45 +317,61 @@ public virtual AsyncPageable GetAllAsync(Cance /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _grafanaIntegrationFabricIntegrationFabricsRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _grafanaIntegrationFabricIntegrationFabricsRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new GrafanaIntegrationFabricResource(Client, GrafanaIntegrationFabricData.DeserializeGrafanaIntegrationFabricData(e)), _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics, Pipeline, "GrafanaIntegrationFabricCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new IntegrationFabricsGetAllCollectionResultOfT(_integrationFabricsRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new GrafanaIntegrationFabricResource(Client, data)); } /// - /// Checks to see if the resource exists in azure. + /// Get a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Operation Id - /// IntegrationFabric_Get + /// Operation Id. + /// IntegrationFabrics_Get. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The integration fabric name of Azure Managed Grafana. /// 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 integrationFabricName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.Exists"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.Exists"); scope.Start(); try { - var response = await _grafanaIntegrationFabricIntegrationFabricsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((GrafanaIntegrationFabricData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -343,39 +382,53 @@ public virtual async Task> ExistsAsync(string integrationFabricNa } /// - /// Checks to see if the resource exists in azure. + /// Get a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} - /// - /// - /// Operation Id - /// IntegrationFabric_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// IntegrationFabrics_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The integration fabric name of Azure Managed Grafana. /// 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 integrationFabricName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.Exists"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.Exists"); scope.Start(); try { - var response = _grafanaIntegrationFabricIntegrationFabricsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((GrafanaIntegrationFabricData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -386,41 +439,57 @@ public virtual Response Exists(string integrationFabricName, CancellationT } /// - /// Tries to get details for this resource from the service. + /// Get a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} - /// - /// - /// Operation Id - /// IntegrationFabric_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// IntegrationFabrics_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The integration fabric name of Azure Managed Grafana. /// 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 integrationFabricName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.GetIfExists"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.GetIfExists"); scope.Start(); try { - var response = await _grafanaIntegrationFabricIntegrationFabricsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((GrafanaIntegrationFabricData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new GrafanaIntegrationFabricResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -431,41 +500,57 @@ public virtual async Task> Ge } /// - /// Tries to get details for this resource from the service. + /// Get a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Operation Id - /// IntegrationFabric_Get + /// Operation Id. + /// IntegrationFabrics_Get. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The integration fabric name of Azure Managed Grafana. /// 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 integrationFabricName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.GetIfExists"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricCollection.GetIfExists"); scope.Start(); try { - var response = _grafanaIntegrationFabricIntegrationFabricsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, integrationFabricName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((GrafanaIntegrationFabricData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new GrafanaIntegrationFabricResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -485,6 +570,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetAll().GetEnumerator(); } + /// The cancellation token to use. IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) { return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricData.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricData.Serialization.cs index 1d59b6d9d099..9ad8197eac3d 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricData.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricData.Serialization.cs @@ -10,16 +10,23 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.Grafana.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.Grafana { - public partial class GrafanaIntegrationFabricData : IUtf8JsonSerializable, IJsonModel + /// The integration fabric resource type. + public partial class GrafanaIntegrationFabricData : TrackedResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal GrafanaIntegrationFabricData() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,12 +38,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// 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(GrafanaIntegrationFabricData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Properties)) { @@ -45,110 +51,127 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - GrafanaIntegrationFabricData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaIntegrationFabricData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (GrafanaIntegrationFabricData)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(GrafanaIntegrationFabricData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaIntegrationFabricData(document.RootElement, options); } - internal static GrafanaIntegrationFabricData DeserializeGrafanaIntegrationFabricData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaIntegrationFabricData DeserializeGrafanaIntegrationFabricData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - GrafanaIntegrationFabricProperties properties = default; - IDictionary tags = default; - AzureLocation location = default; - ResourceIdentifier id = default; + string id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + GrafanaIntegrationFabricProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("id"u8)) + { + id = 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 (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = GrafanaIntegrationFabricProperties.DeserializeGrafanaIntegrationFabricProperties(property.Value, options); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerGrafanaContext.Default); continue; } - if (property.NameEquals("tags"u8)) + if (prop.NameEquals("tags"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()); + } } tags = dictionary; continue; } - if (property.NameEquals("location"u8)) - { - location = new AzureLocation(property.Value.GetString()); - continue; - } - if (property.NameEquals("id"u8)) - { - id = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("location"u8)) { - name = property.Value.GetString(); + location = new AzureLocation(prop.Value.GetString()); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("properties"u8)) { - type = new ResourceType(property.Value.GetString()); - continue; - } - if (property.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, AzureResourceManagerGrafanaContext.Default); + properties = GrafanaIntegrationFabricProperties.DeserializeGrafanaIntegrationFabricProperties(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 GrafanaIntegrationFabricData( id, name, - type, + resourceType, systemData, + additionalBinaryDataProperties, tags ?? new ChangeTrackingDictionary(), location, - properties, - serializedAdditionalRawData); + 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": @@ -158,15 +181,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - GrafanaIntegrationFabricData 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. + GrafanaIntegrationFabricData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (GrafanaIntegrationFabricData)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 DeserializeGrafanaIntegrationFabricData(document.RootElement, options); } default: @@ -174,6 +202,26 @@ GrafanaIntegrationFabricData IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(GrafanaIntegrationFabricData grafanaIntegrationFabricData) + { + if (grafanaIntegrationFabricData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(grafanaIntegrationFabricData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static GrafanaIntegrationFabricData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGrafanaIntegrationFabricData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricData.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricData.cs index 0817ba696f29..7d4f4ab563d7 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricData.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricData.cs @@ -13,71 +13,34 @@ namespace Azure.ResourceManager.Grafana { - /// - /// A class representing the GrafanaIntegrationFabric data model. - /// The integration fabric resource type. - /// + /// The integration fabric resource type. public partial class GrafanaIntegrationFabricData : TrackedResourceData { - /// - /// 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 location. + /// The geo-location where the resource lives. public GrafanaIntegrationFabricData(AzureLocation location) : base(location) { } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. /// - /// Keeps track of any properties unknown to the library. - internal GrafanaIntegrationFabricData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, GrafanaIntegrationFabricProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + internal GrafanaIntegrationFabricData(string id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, GrafanaIntegrationFabricProperties properties) : base(id, name, resourceType, systemData, tags, location) { + _additionalBinaryDataProperties = additionalBinaryDataProperties; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal GrafanaIntegrationFabricData() - { - } - - /// Gets or sets the properties. + /// Gets or sets the Properties. public GrafanaIntegrationFabricProperties Properties { get; set; } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricResource.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricResource.Serialization.cs index 5c006b38fe13..b4ac8d7d0559 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricResource.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.Grafana { + /// public partial class GrafanaIntegrationFabricResource : IJsonModel { - private static GrafanaIntegrationFabricData s_dataDeserializationInstance; - private static GrafanaIntegrationFabricData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new GrafanaIntegrationFabricData(); + + /// 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); - GrafanaIntegrationFabricData 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. + GrafanaIntegrationFabricData 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, AzureResourceManagerGrafanaContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. GrafanaIntegrationFabricData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerGrafanaContext.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/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricResource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricResource.cs index 9a3e4c3ffc01..3bbffa52747c 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricResource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaIntegrationFabricResource.cs @@ -7,47 +7,37 @@ using System; using System.Collections.Generic; -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.Grafana.Models; +using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.Grafana { /// - /// A Class representing a GrafanaIntegrationFabric 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 GetGrafanaIntegrationFabricResource method. - /// Otherwise you can get one from its parent resource using the GetGrafanaIntegrationFabric method. + /// A class representing a GrafanaIntegrationFabric 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 GetGrafanaIntegrationFabrics method. /// public partial class GrafanaIntegrationFabricResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The workspaceName. - /// The integrationFabricName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics; - private readonly IntegrationFabricsRestOperations _grafanaIntegrationFabricIntegrationFabricsRestClient; + private readonly ClientDiagnostics _integrationFabricsClientDiagnostics; + private readonly IntegrationFabrics _integrationFabricsRestClient; private readonly GrafanaIntegrationFabricData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Dashboard/grafana/integrationFabrics"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of GrafanaIntegrationFabricResource for mocking. protected GrafanaIntegrationFabricResource() { } - /// 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 GrafanaIntegrationFabricResource(ArmClient client, GrafanaIntegrationFabricData data) : this(client, data.Id) @@ -56,71 +46,93 @@ internal GrafanaIntegrationFabricResource(ArmClient client, GrafanaIntegrationFa _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 GrafanaIntegrationFabricResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string grafanaIntegrationFabricIntegrationFabricsApiVersion); - _grafanaIntegrationFabricIntegrationFabricsRestClient = new IntegrationFabricsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, grafanaIntegrationFabricIntegrationFabricsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string grafanaIntegrationFabricApiVersion); + _integrationFabricsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ResourceType.Namespace, Diagnostics); + _integrationFabricsRestClient = new IntegrationFabrics(_integrationFabricsClientDiagnostics, Pipeline, Endpoint, grafanaIntegrationFabricApiVersion ?? "2025-09-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 GrafanaIntegrationFabricData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The workspaceName. + /// The integrationFabricName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}"; + 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 a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Operation Id - /// IntegrationFabric_Get + /// Operation Id. + /// IntegrationFabrics_Get. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.Get"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.Get"); scope.Start(); try { - var response = await _grafanaIntegrationFabricIntegrationFabricsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new GrafanaIntegrationFabricResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -134,33 +146,41 @@ public virtual async Task> GetAsync(C /// Get a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Operation Id - /// IntegrationFabric_Get + /// Operation Id. + /// IntegrationFabrics_Get. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.Get"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.Get"); scope.Start(); try { - var response = _grafanaIntegrationFabricIntegrationFabricsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new GrafanaIntegrationFabricResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -171,38 +191,55 @@ public virtual Response Get(CancellationToken } /// - /// Delete a IntegrationFabric + /// Update a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Operation Id - /// IntegrationFabric_Delete + /// Operation Id. + /// IntegrationFabrics_Update. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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 cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, GrafanaIntegrationFabricPatch patch, CancellationToken cancellationToken = default) { - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.Update"); scope.Start(); try { - var response = await _grafanaIntegrationFabricIntegrationFabricsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(_grafanaIntegrationFabricIntegrationFabricsClientDiagnostics, Pipeline, _grafanaIntegrationFabricIntegrationFabricsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, GrafanaIntegrationFabricPatch.ToRequestContent(patch), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + GrafanaArmOperation operation = new GrafanaArmOperation( + new GrafanaIntegrationFabricOperationSource(Client), + _integrationFabricsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -213,38 +250,55 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell } /// - /// Delete a IntegrationFabric + /// Update a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Operation Id - /// IntegrationFabric_Delete + /// Operation Id. + /// IntegrationFabrics_Update. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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 cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, GrafanaIntegrationFabricPatch patch, CancellationToken cancellationToken = default) { - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.Update"); scope.Start(); try { - var response = _grafanaIntegrationFabricIntegrationFabricsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new GrafanaArmOperation(_grafanaIntegrationFabricIntegrationFabricsClientDiagnostics, Pipeline, _grafanaIntegrationFabricIntegrationFabricsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, GrafanaIntegrationFabricPatch.ToRequestContent(patch), context); + Response response = Pipeline.ProcessMessage(message, context); + GrafanaArmOperation operation = new GrafanaArmOperation( + new GrafanaIntegrationFabricOperationSource(Client), + _integrationFabricsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); + { + operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -255,42 +309,51 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel } /// - /// Update a IntegrationFabric + /// Delete a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Operation Id - /// IntegrationFabric_Update + /// Operation Id. + /// IntegrationFabrics_Delete. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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 to use. /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, GrafanaIntegrationFabricPatch patch, CancellationToken cancellationToken = default) + public virtual async Task> DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.Update"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.Delete"); scope.Start(); try { - var response = await _grafanaIntegrationFabricIntegrationFabricsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(new GrafanaIntegrationFabricOperationSource(Client), _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics, Pipeline, _grafanaIntegrationFabricIntegrationFabricsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + GrafanaArmOperation operation = new GrafanaArmOperation( + new GrafanaIntegrationFabricOperationSource(Client), + _integrationFabricsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -301,42 +364,51 @@ public virtual async Task> Update } /// - /// Update a IntegrationFabric + /// Delete a IntegrationFabric /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}. /// /// - /// Operation Id - /// IntegrationFabric_Update + /// Operation Id. + /// IntegrationFabrics_Delete. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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 to use. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, GrafanaIntegrationFabricPatch patch, CancellationToken cancellationToken = default) + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.Update"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.Delete"); scope.Start(); try { - var response = _grafanaIntegrationFabricIntegrationFabricsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); - var operation = new GrafanaArmOperation(new GrafanaIntegrationFabricOperationSource(Client), _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics, Pipeline, _grafanaIntegrationFabricIntegrationFabricsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + GrafanaArmOperation operation = new GrafanaArmOperation( + new GrafanaIntegrationFabricOperationSource(Client), + _integrationFabricsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -346,27 +418,7 @@ public virtual ArmOperation Update(WaitUntil w } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} - /// - /// - /// Operation Id - /// IntegrationFabric_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -376,28 +428,34 @@ public virtual async Task> AddTagAsyn Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.AddTag"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.AddTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues[key] = value; - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _grafanaIntegrationFabricIntegrationFabricsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new GrafanaIntegrationFabricResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); + return Response.FromValue(new GrafanaIntegrationFabricResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new GrafanaIntegrationFabricPatch(); - foreach (var tag in current.Tags) + GrafanaIntegrationFabricData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + GrafanaIntegrationFabricPatch patch = new GrafanaIntegrationFabricPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -408,27 +466,7 @@ public virtual async Task> AddTagAsyn } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} - /// - /// - /// Operation Id - /// IntegrationFabric_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -438,28 +476,34 @@ public virtual Response AddTag(string key, str Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.AddTag"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.AddTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues[key] = value; - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _grafanaIntegrationFabricIntegrationFabricsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new GrafanaIntegrationFabricResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); + return Response.FromValue(new GrafanaIntegrationFabricResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new GrafanaIntegrationFabricPatch(); - foreach (var tag in current.Tags) + GrafanaIntegrationFabricData current = Get(cancellationToken: cancellationToken).Value.Data; + GrafanaIntegrationFabricPatch patch = new GrafanaIntegrationFabricPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -470,53 +514,39 @@ public virtual Response AddTag(string key, str } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} - /// - /// - /// Operation Id - /// IntegrationFabric_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// The cancellation token to use. /// is null. public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.SetTags"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.SetTags"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.ReplaceWith(tags); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _grafanaIntegrationFabricIntegrationFabricsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new GrafanaIntegrationFabricResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); + return Response.FromValue(new GrafanaIntegrationFabricResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new GrafanaIntegrationFabricPatch(); + GrafanaIntegrationFabricData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + GrafanaIntegrationFabricPatch patch = new GrafanaIntegrationFabricPatch(); patch.Tags.ReplaceWith(tags); - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -527,53 +557,39 @@ public virtual async Task> SetTagsAsy } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} - /// - /// - /// Operation Id - /// IntegrationFabric_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// The cancellation token to use. /// is null. public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.SetTags"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.SetTags"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); - var originalTags = GetTagResource().Get(cancellationToken); + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.ReplaceWith(tags); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _grafanaIntegrationFabricIntegrationFabricsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new GrafanaIntegrationFabricResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); + return Response.FromValue(new GrafanaIntegrationFabricResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new GrafanaIntegrationFabricPatch(); + GrafanaIntegrationFabricData current = Get(cancellationToken: cancellationToken).Value.Data; + GrafanaIntegrationFabricPatch patch = new GrafanaIntegrationFabricPatch(); patch.Tags.ReplaceWith(tags); - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -584,27 +600,7 @@ public virtual Response SetTags(IDictionary - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} - /// - /// - /// Operation Id - /// IntegrationFabric_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -612,28 +608,34 @@ public virtual async Task> RemoveTagA { Argument.AssertNotNull(key, nameof(key)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.RemoveTag"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.RemoveTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.Remove(key); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _grafanaIntegrationFabricIntegrationFabricsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new GrafanaIntegrationFabricResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); + return Response.FromValue(new GrafanaIntegrationFabricResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new GrafanaIntegrationFabricPatch(); - foreach (var tag in current.Tags) + GrafanaIntegrationFabricData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + GrafanaIntegrationFabricPatch patch = new GrafanaIntegrationFabricPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -644,27 +646,7 @@ public virtual async Task> RemoveTagA } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} - /// - /// - /// Operation Id - /// IntegrationFabric_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -672,28 +654,34 @@ public virtual Response RemoveTag(string key, { Argument.AssertNotNull(key, nameof(key)); - using var scope = _grafanaIntegrationFabricIntegrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.RemoveTag"); + using DiagnosticScope scope = _integrationFabricsClientDiagnostics.CreateScope("GrafanaIntegrationFabricResource.RemoveTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.Remove(key); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _grafanaIntegrationFabricIntegrationFabricsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new GrafanaIntegrationFabricResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _integrationFabricsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(GrafanaIntegrationFabricData.FromResponse(result), result); + return Response.FromValue(new GrafanaIntegrationFabricResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new GrafanaIntegrationFabricPatch(); - foreach (var tag in current.Tags) + GrafanaIntegrationFabricData current = Get(cancellationToken: cancellationToken).Value.Data; + GrafanaIntegrationFabricPatch patch = new GrafanaIntegrationFabricPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionCollection.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionCollection.cs index 4ed6722f0757..5e80d1d8e707 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionCollection.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionCollection.cs @@ -8,12 +8,13 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.Grafana { @@ -24,128 +25,32 @@ namespace Azure.ResourceManager.Grafana /// public partial class GrafanaPrivateEndpointConnectionCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics; - private readonly PrivateEndpointConnectionsRestOperations _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient; + private readonly ClientDiagnostics _privateEndpointConnectionsClientDiagnostics; + private readonly PrivateEndpointConnections _privateEndpointConnectionsRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of GrafanaPrivateEndpointConnectionCollection for mocking. protected GrafanaPrivateEndpointConnectionCollection() { } - /// 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 GrafanaPrivateEndpointConnectionCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", GrafanaPrivateEndpointConnectionResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(GrafanaPrivateEndpointConnectionResource.ResourceType, out string grafanaPrivateEndpointConnectionPrivateEndpointConnectionsApiVersion); - _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient = new PrivateEndpointConnectionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, grafanaPrivateEndpointConnectionPrivateEndpointConnectionsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(GrafanaPrivateEndpointConnectionResource.ResourceType, out string grafanaPrivateEndpointConnectionApiVersion); + _privateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", GrafanaPrivateEndpointConnectionResource.ResourceType.Namespace, Diagnostics); + _privateEndpointConnectionsRestClient = new PrivateEndpointConnections(_privateEndpointConnectionsClientDiagnostics, Pipeline, Endpoint, grafanaPrivateEndpointConnectionApiVersion ?? "2025-09-01-preview"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ManagedGrafanaResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagedGrafanaResource.ResourceType), nameof(id)); - } - - /// - /// Manual approve private endpoint connection - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_Approve - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The private endpoint connection name of Azure Managed Grafana. - /// The to use. - /// 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 privateEndpointConnectionName, GrafanaPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = await _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.ApproveAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(new GrafanaPrivateEndpointConnectionOperationSource(Client), _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateApproveRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Manual approve private endpoint connection - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_Approve - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The private endpoint connection name of Azure Managed Grafana. - /// The to use. - /// 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 privateEndpointConnectionName, GrafanaPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Approve(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data, cancellationToken); - var operation = new GrafanaArmOperation(new GrafanaPrivateEndpointConnectionOperationSource(Client), _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateApproveRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); - return operation; - } - catch (Exception e) { - scope.Failed(e); - throw; + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ManagedGrafanaResource.ResourceType), id); } } @@ -153,38 +58,42 @@ public virtual ArmOperation CreateOrUp /// Get private endpoint connections. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// PrivateEndpointConnections_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The private endpoint connection name of Azure Managed Grafana. /// 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.Get"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.Get"); scope.Start(); try { - var response = await _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(GrafanaPrivateEndpointConnectionData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new GrafanaPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -198,38 +107,42 @@ public virtual async Task> Ge /// Get private endpoint connections. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// PrivateEndpointConnections_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The private endpoint connection name of Azure Managed Grafana. /// 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.Get"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.Get"); scope.Start(); try { - var response = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(GrafanaPrivateEndpointConnectionData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new GrafanaPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -243,50 +156,44 @@ public virtual Response Get(string pri /// Get private endpoint connection /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections. /// /// - /// Operation Id - /// PrivateEndpointConnection_List + /// Operation Id. + /// PrivateEndpointConnections_List. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new GrafanaPrivateEndpointConnectionResource(Client, GrafanaPrivateEndpointConnectionData.DeserializeGrafanaPrivateEndpointConnectionData(e)), _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, "GrafanaPrivateEndpointConnectionCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new PrivateEndpointConnectionsGetAllAsyncCollectionResultOfT(_privateEndpointConnectionsRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new GrafanaPrivateEndpointConnectionResource(Client, data)); } /// /// Get private endpoint connection /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections - /// - /// - /// Operation Id - /// PrivateEndpointConnection_List + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// PrivateEndpointConnections_List. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -294,45 +201,61 @@ public virtual AsyncPageable GetAllAsy /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new GrafanaPrivateEndpointConnectionResource(Client, GrafanaPrivateEndpointConnectionData.DeserializeGrafanaPrivateEndpointConnectionData(e)), _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, "GrafanaPrivateEndpointConnectionCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new PrivateEndpointConnectionsGetAllCollectionResultOfT(_privateEndpointConnectionsRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new GrafanaPrivateEndpointConnectionResource(Client, data)); } /// - /// Checks to see if the resource exists in azure. + /// Get private endpoint connections. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_Get + /// Operation Id. + /// PrivateEndpointConnections_Get. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The private endpoint connection name of Azure Managed Grafana. /// 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.Exists"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.Exists"); scope.Start(); try { - var response = await _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(GrafanaPrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((GrafanaPrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -343,39 +266,53 @@ public virtual async Task> ExistsAsync(string privateEndpointConn } /// - /// Checks to see if the resource exists in azure. + /// Get private endpoint connections. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// PrivateEndpointConnections_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The private endpoint connection name of Azure Managed Grafana. /// 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.Exists"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.Exists"); scope.Start(); try { - var response = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(GrafanaPrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((GrafanaPrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -386,41 +323,57 @@ public virtual Response Exists(string privateEndpointConnectionName, Cance } /// - /// Tries to get details for this resource from the service. + /// Get private endpoint connections. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// PrivateEndpointConnections_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The private endpoint connection name of Azure Managed Grafana. /// 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.GetIfExists"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.GetIfExists"); scope.Start(); try { - var response = await _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(GrafanaPrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((GrafanaPrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new GrafanaPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -431,41 +384,57 @@ public virtual async Task - /// Tries to get details for this resource from the service. + /// Get private endpoint connections. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_Get + /// Operation Id. + /// PrivateEndpointConnections_Get. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The private endpoint connection name of Azure Managed Grafana. /// 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.GetIfExists"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionCollection.GetIfExists"); scope.Start(); try { - var response = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(GrafanaPrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((GrafanaPrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new GrafanaPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -485,6 +454,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetAll().GetEnumerator(); } + /// The cancellation token to use. IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) { return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionData.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionData.Serialization.cs index 3677170dabcb..baabb9a9ee93 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionData.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionData.Serialization.cs @@ -10,17 +10,18 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.Grafana.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources.Models; namespace Azure.ResourceManager.Grafana { - public partial class GrafanaPrivateEndpointConnectionData : IUtf8JsonSerializable, IJsonModel + /// The Private Endpoint Connection resource. + public partial class GrafanaPrivateEndpointConnectionData : 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(); @@ -32,174 +33,110 @@ void IJsonModel.Write(Utf8JsonWriter write /// 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(GrafanaPrivateEndpointConnectionData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(PrivateEndpoint)) - { - writer.WritePropertyName("privateEndpoint"u8); - ((IJsonModel)PrivateEndpoint).Write(writer, options); - } - if (Optional.IsDefined(ConnectionState)) - { - writer.WritePropertyName("privateLinkServiceConnectionState"u8); - writer.WriteObjectValue(ConnectionState, options); - } - if (Optional.IsCollectionDefined(GroupIds)) - { - writer.WritePropertyName("groupIds"u8); - writer.WriteStartArray(); - foreach (var item in GroupIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - 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); } - writer.WriteEndObject(); } - GrafanaPrivateEndpointConnectionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaPrivateEndpointConnectionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (GrafanaPrivateEndpointConnectionData)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(GrafanaPrivateEndpointConnectionData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaPrivateEndpointConnectionData(document.RootElement, options); } - internal static GrafanaPrivateEndpointConnectionData DeserializeGrafanaPrivateEndpointConnectionData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaPrivateEndpointConnectionData DeserializeGrafanaPrivateEndpointConnectionData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - ResourceIdentifier id = default; + string id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - SubResource privateEndpoint = default; - GrafanaPrivateLinkServiceConnectionState privateLinkServiceConnectionState = default; - IList groupIds = default; - GrafanaPrivateEndpointConnectionProvisioningState? provisioningState = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + PrivateEndpointConnectionProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + id = 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, AzureResourceManagerGrafanaContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerGrafanaContext.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("privateEndpoint"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - privateEndpoint = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureResourceManagerGrafanaContext.Default); - continue; - } - if (property0.NameEquals("privateLinkServiceConnectionState"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - privateLinkServiceConnectionState = GrafanaPrivateLinkServiceConnectionState.DeserializeGrafanaPrivateLinkServiceConnectionState(property0.Value, options); - continue; - } - if (property0.NameEquals("groupIds"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - groupIds = array; - continue; - } - if (property0.NameEquals("provisioningState"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new GrafanaPrivateEndpointConnectionProvisioningState(property0.Value.GetString()); - continue; - } - } + properties = PrivateEndpointConnectionProperties.DeserializePrivateEndpointConnectionProperties(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 GrafanaPrivateEndpointConnectionData( id, name, - type, + resourceType, systemData, - privateEndpoint, - privateLinkServiceConnectionState, - groupIds ?? new ChangeTrackingList(), - provisioningState, - 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": @@ -209,15 +146,20 @@ BinaryData IPersistableModel.Write(ModelRe } } - GrafanaPrivateEndpointConnectionData 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. + GrafanaPrivateEndpointConnectionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (GrafanaPrivateEndpointConnectionData)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 DeserializeGrafanaPrivateEndpointConnectionData(document.RootElement, options); } default: @@ -225,6 +167,26 @@ GrafanaPrivateEndpointConnectionData IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(GrafanaPrivateEndpointConnectionData grafanaPrivateEndpointConnectionData) + { + if (grafanaPrivateEndpointConnectionData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(grafanaPrivateEndpointConnectionData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static GrafanaPrivateEndpointConnectionData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGrafanaPrivateEndpointConnectionData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionData.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionData.cs index 66fb0740e387..d193c692780f 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionData.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionData.cs @@ -10,86 +10,78 @@ using Azure.Core; using Azure.ResourceManager.Grafana.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources.Models; namespace Azure.ResourceManager.Grafana { - /// - /// A class representing the GrafanaPrivateEndpointConnection data model. - /// The Private Endpoint Connection resource. - /// + /// The Private Endpoint Connection resource. public partial class GrafanaPrivateEndpointConnectionData : 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 GrafanaPrivateEndpointConnectionData() { - GroupIds = new ChangeTrackingList(); } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The resource of private end point. - /// A collection of information about the state of the connection between service consumer and provider. - /// The private endpoint connection group ids. - /// The provisioning state of the private endpoint connection resource. - /// Keeps track of any properties unknown to the library. - internal GrafanaPrivateEndpointConnectionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, SubResource privateEndpoint, GrafanaPrivateLinkServiceConnectionState connectionState, IList groupIds, GrafanaPrivateEndpointConnectionProvisioningState? provisioningState, 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. + /// Resource properties. + internal GrafanaPrivateEndpointConnectionData(string id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, PrivateEndpointConnectionProperties properties) : base(id, name, resourceType, systemData) { - PrivateEndpoint = privateEndpoint; - ConnectionState = connectionState; - GroupIds = groupIds; - ProvisioningState = provisioningState; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; } - /// The resource of private end point. - internal SubResource PrivateEndpoint { get; set; } - /// Gets Id. - public ResourceIdentifier PrivateEndpointId + /// Resource properties. + internal PrivateEndpointConnectionProperties Properties { get; set; } + + /// A collection of information about the state of the connection between service consumer and provider. + public GrafanaPrivateLinkServiceConnectionState ConnectionState { - get => PrivateEndpoint is null ? default : PrivateEndpoint.Id; + get + { + return Properties is null ? default : Properties.ConnectionState; + } + set + { + if (Properties is null) + { + Properties = new PrivateEndpointConnectionProperties(); + } + Properties.ConnectionState = value; + } } - /// A collection of information about the state of the connection between service consumer and provider. - public GrafanaPrivateLinkServiceConnectionState ConnectionState { get; set; } /// The private endpoint connection group ids. - public IList GroupIds { get; } + public IList GroupIds + { + get + { + return Properties is null ? default : Properties.GroupIds; + } + } + /// The provisioning state of the private endpoint connection resource. - public GrafanaPrivateEndpointConnectionProvisioningState? ProvisioningState { get; } + public GrafanaPrivateEndpointConnectionProvisioningState? ProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } + + /// The resource identifier of the private endpoint. + public string PrivateEndpointId + { + get + { + return Properties is null ? default : Properties.PrivateEndpointId; + } + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionResource.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionResource.Serialization.cs index 2141619d3cb1..7a1bb621f548 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionResource.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.Grafana { + /// public partial class GrafanaPrivateEndpointConnectionResource : IJsonModel { - private static GrafanaPrivateEndpointConnectionData s_dataDeserializationInstance; - private static GrafanaPrivateEndpointConnectionData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new GrafanaPrivateEndpointConnectionData(); + + /// 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); - GrafanaPrivateEndpointConnectionData 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. + GrafanaPrivateEndpointConnectionData 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, AzureResourceManagerGrafanaContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. GrafanaPrivateEndpointConnectionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerGrafanaContext.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/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionResource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionResource.cs index afa51473d144..e7388f92a704 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionResource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateEndpointConnectionResource.cs @@ -6,46 +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.Grafana { /// - /// A Class representing a GrafanaPrivateEndpointConnection 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 GetGrafanaPrivateEndpointConnectionResource method. - /// Otherwise you can get one from its parent resource using the GetGrafanaPrivateEndpointConnection method. + /// A class representing a GrafanaPrivateEndpointConnection 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 GetGrafanaPrivateEndpointConnections method. /// public partial class GrafanaPrivateEndpointConnectionResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The workspaceName. - /// The privateEndpointConnectionName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics; - private readonly PrivateEndpointConnectionsRestOperations _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient; + private readonly ClientDiagnostics _privateEndpointConnectionsClientDiagnostics; + private readonly PrivateEndpointConnections _privateEndpointConnectionsRestClient; private readonly GrafanaPrivateEndpointConnectionData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Dashboard/grafana/privateEndpointConnections"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of GrafanaPrivateEndpointConnectionResource for mocking. protected GrafanaPrivateEndpointConnectionResource() { } - /// 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 GrafanaPrivateEndpointConnectionResource(ArmClient client, GrafanaPrivateEndpointConnectionData data) : this(client, data.Id) @@ -54,71 +43,93 @@ internal GrafanaPrivateEndpointConnectionResource(ArmClient client, GrafanaPriva _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 GrafanaPrivateEndpointConnectionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string grafanaPrivateEndpointConnectionPrivateEndpointConnectionsApiVersion); - _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient = new PrivateEndpointConnectionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, grafanaPrivateEndpointConnectionPrivateEndpointConnectionsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string grafanaPrivateEndpointConnectionApiVersion); + _privateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ResourceType.Namespace, Diagnostics); + _privateEndpointConnectionsRestClient = new PrivateEndpointConnections(_privateEndpointConnectionsClientDiagnostics, Pipeline, Endpoint, grafanaPrivateEndpointConnectionApiVersion ?? "2025-09-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 GrafanaPrivateEndpointConnectionData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The workspaceName. + /// The privateEndpointConnectionName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"; + 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 private endpoint connections. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_Get + /// Operation Id. + /// PrivateEndpointConnections_Get. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionResource.Get"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionResource.Get"); scope.Start(); try { - var response = await _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(GrafanaPrivateEndpointConnectionData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new GrafanaPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -132,33 +143,41 @@ public virtual async Task> Ge /// Get private endpoint connections. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_Get + /// Operation Id. + /// PrivateEndpointConnections_Get. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionResource.Get"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionResource.Get"); scope.Start(); try { - var response = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(GrafanaPrivateEndpointConnectionData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new GrafanaPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -172,20 +191,20 @@ public virtual Response Get(Cancellati /// Delete private endpoint connection /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_Delete + /// Operation Id. + /// PrivateEndpointConnections_Delete. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -193,14 +212,21 @@ public virtual Response Get(Cancellati /// The cancellation token to use. public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionResource.Delete"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionResource.Delete"); scope.Start(); try { - var response = await _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(_grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + GrafanaArmOperation operation = new GrafanaArmOperation(_privateEndpointConnectionsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -214,20 +240,20 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// Delete private endpoint connection /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_Delete + /// Operation Id. + /// PrivateEndpointConnections_Delete. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -235,106 +261,21 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// The cancellation token to use. public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionResource.Delete"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionResource.Delete"); scope.Start(); try { - var response = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new GrafanaArmOperation(_grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + GrafanaArmOperation operation = new GrafanaArmOperation(_privateEndpointConnectionsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletionResponse(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Manual approve private endpoint connection - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_Approve - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The to use. - /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, GrafanaPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionResource.Update"); - scope.Start(); - try - { - var response = await _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.ApproveAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(new GrafanaPrivateEndpointConnectionOperationSource(Client), _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateApproveRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, 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; - } - } - - /// - /// Manual approve private endpoint connection - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_Approve - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The to use. - /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, GrafanaPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("GrafanaPrivateEndpointConnectionResource.Update"); - scope.Start(); - try - { - var response = _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Approve(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); - var operation = new GrafanaArmOperation(new GrafanaPrivateEndpointConnectionOperationSource(Client), _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _grafanaPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateApproveRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResource.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResource.Serialization.cs index 726c1d3ffd15..0efca39bb68d 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResource.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.Grafana { + /// public partial class GrafanaPrivateLinkResource : IJsonModel { - private static GrafanaPrivateLinkResourceData s_dataDeserializationInstance; - private static GrafanaPrivateLinkResourceData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new GrafanaPrivateLinkResourceData(); + + /// 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); - GrafanaPrivateLinkResourceData 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. + GrafanaPrivateLinkResourceData 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, AzureResourceManagerGrafanaContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. GrafanaPrivateLinkResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerGrafanaContext.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/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResource.cs index 61868eae4bf9..d4ad9733c33c 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResource.cs @@ -6,46 +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.Grafana { /// - /// A Class representing a GrafanaPrivateLinkResource 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 GetGrafanaPrivateLinkResource method. - /// Otherwise you can get one from its parent resource using the GetGrafanaPrivateLinkResource method. + /// A class representing a GrafanaPrivateLinkResource 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 GetGrafanaPrivateLinkResources method. /// public partial class GrafanaPrivateLinkResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The workspaceName. - /// The privateLinkResourceName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName, string privateLinkResourceName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics; - private readonly PrivateLinkResourcesRestOperations _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient; + private readonly ClientDiagnostics _privateLinkResourcesClientDiagnostics; + private readonly PrivateLinkResources _privateLinkResourcesRestClient; private readonly GrafanaPrivateLinkResourceData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Dashboard/grafana/privateLinkResources"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of GrafanaPrivateLinkResource for mocking. protected GrafanaPrivateLinkResource() { } - /// 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 GrafanaPrivateLinkResource(ArmClient client, GrafanaPrivateLinkResourceData data) : this(client, data.Id) @@ -54,71 +43,93 @@ internal GrafanaPrivateLinkResource(ArmClient client, GrafanaPrivateLinkResource _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 GrafanaPrivateLinkResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string grafanaPrivateLinkResourcePrivateLinkResourcesApiVersion); - _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient = new PrivateLinkResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, grafanaPrivateLinkResourcePrivateLinkResourcesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string grafanaPrivateLinkResourceApiVersion); + _privateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ResourceType.Namespace, Diagnostics); + _privateLinkResourcesRestClient = new PrivateLinkResources(_privateLinkResourcesClientDiagnostics, Pipeline, Endpoint, grafanaPrivateLinkResourceApiVersion ?? "2025-09-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 GrafanaPrivateLinkResourceData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The workspaceName. + /// The privateLinkResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName, string privateLinkResourceName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName}"; + 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 specific private link resource information for this grafana resource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName}. /// /// - /// Operation Id - /// PrivateLinkResource_Get + /// Operation Id. + /// PrivateLinkResources_Get. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResource.Get"); + using DiagnosticScope scope = _privateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResource.Get"); scope.Start(); try { - var response = await _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateLinkResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(GrafanaPrivateLinkResourceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new GrafanaPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -132,33 +143,41 @@ public virtual async Task> GetAsync(Cancell /// Get specific private link resource information for this grafana resource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName}. /// /// - /// Operation Id - /// PrivateLinkResource_Get + /// Operation Id. + /// PrivateLinkResources_Get. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResource.Get"); + using DiagnosticScope scope = _privateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResource.Get"); scope.Start(); try { - var response = _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateLinkResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(GrafanaPrivateLinkResourceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new GrafanaPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResourceCollection.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResourceCollection.cs index 2e77b63b7518..28c47c6dc477 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResourceCollection.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResourceCollection.cs @@ -8,12 +8,13 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.Grafana { @@ -24,69 +25,75 @@ namespace Azure.ResourceManager.Grafana /// public partial class GrafanaPrivateLinkResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics; - private readonly PrivateLinkResourcesRestOperations _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient; + private readonly ClientDiagnostics _privateLinkResourcesClientDiagnostics; + private readonly PrivateLinkResources _privateLinkResourcesRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of GrafanaPrivateLinkResourceCollection for mocking. protected GrafanaPrivateLinkResourceCollection() { } - /// 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 GrafanaPrivateLinkResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", GrafanaPrivateLinkResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(GrafanaPrivateLinkResource.ResourceType, out string grafanaPrivateLinkResourcePrivateLinkResourcesApiVersion); - _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient = new PrivateLinkResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, grafanaPrivateLinkResourcePrivateLinkResourcesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(GrafanaPrivateLinkResource.ResourceType, out string grafanaPrivateLinkResourceApiVersion); + _privateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", GrafanaPrivateLinkResource.ResourceType.Namespace, Diagnostics); + _privateLinkResourcesRestClient = new PrivateLinkResources(_privateLinkResourcesClientDiagnostics, Pipeline, Endpoint, grafanaPrivateLinkResourceApiVersion ?? "2025-09-01-preview"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ManagedGrafanaResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagedGrafanaResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ManagedGrafanaResource.ResourceType), id); + } } /// /// Get specific private link resource information for this grafana resource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName}. /// /// - /// Operation Id - /// PrivateLinkResource_Get + /// Operation Id. + /// PrivateLinkResources_Get. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// - /// The to use. + /// /// 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 privateLinkResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); - using var scope = _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.Get"); + using DiagnosticScope scope = _privateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.Get"); scope.Start(); try { - var response = await _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateLinkResourceName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateLinkResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(GrafanaPrivateLinkResourceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new GrafanaPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -100,38 +107,42 @@ public virtual async Task> GetAsync(string /// Get specific private link resource information for this grafana resource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName} - /// - /// - /// Operation Id - /// PrivateLinkResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// PrivateLinkResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// - /// The to use. + /// /// 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 privateLinkResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); - using var scope = _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.Get"); + using DiagnosticScope scope = _privateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.Get"); scope.Start(); try { - var response = _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateLinkResourceName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateLinkResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(GrafanaPrivateLinkResourceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new GrafanaPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -145,50 +156,44 @@ public virtual Response Get(string privateLinkResour /// List all private link resources information for this grafana resource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources. /// /// - /// Operation Id - /// PrivateLinkResource_List + /// Operation Id. + /// PrivateLinkResources_List. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new GrafanaPrivateLinkResource(Client, GrafanaPrivateLinkResourceData.DeserializeGrafanaPrivateLinkResourceData(e)), _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics, Pipeline, "GrafanaPrivateLinkResourceCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new PrivateLinkResourcesGetAllAsyncCollectionResultOfT(_privateLinkResourcesRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new GrafanaPrivateLinkResource(Client, data)); } /// /// List all private link resources information for this grafana resource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources. /// /// - /// Operation Id - /// PrivateLinkResource_List + /// Operation Id. + /// PrivateLinkResources_List. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -196,45 +201,61 @@ public virtual AsyncPageable GetAllAsync(Cancellatio /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new GrafanaPrivateLinkResource(Client, GrafanaPrivateLinkResourceData.DeserializeGrafanaPrivateLinkResourceData(e)), _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics, Pipeline, "GrafanaPrivateLinkResourceCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new PrivateLinkResourcesGetAllCollectionResultOfT(_privateLinkResourcesRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new GrafanaPrivateLinkResource(Client, data)); } /// - /// Checks to see if the resource exists in azure. + /// Get specific private link resource information for this grafana resource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName} - /// - /// - /// Operation Id - /// PrivateLinkResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// PrivateLinkResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// - /// The to use. + /// /// 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 privateLinkResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); - using var scope = _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.Exists"); + using DiagnosticScope scope = _privateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.Exists"); scope.Start(); try { - var response = await _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateLinkResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateLinkResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(GrafanaPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((GrafanaPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -245,39 +266,53 @@ public virtual async Task> ExistsAsync(string privateLinkResource } /// - /// Checks to see if the resource exists in azure. + /// Get specific private link resource information for this grafana resource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName} - /// - /// - /// Operation Id - /// PrivateLinkResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// PrivateLinkResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// - /// The to use. + /// /// 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 privateLinkResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); - using var scope = _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.Exists"); + using DiagnosticScope scope = _privateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.Exists"); scope.Start(); try { - var response = _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateLinkResourceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateLinkResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(GrafanaPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((GrafanaPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -288,41 +323,57 @@ public virtual Response Exists(string privateLinkResourceName, Cancellatio } /// - /// Tries to get details for this resource from the service. + /// Get specific private link resource information for this grafana resource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName}. /// /// - /// Operation Id - /// PrivateLinkResource_Get + /// Operation Id. + /// PrivateLinkResources_Get. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// - /// The to use. + /// /// 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 privateLinkResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); - using var scope = _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.GetIfExists"); + using DiagnosticScope scope = _privateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.GetIfExists"); scope.Start(); try { - var response = await _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateLinkResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateLinkResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(GrafanaPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((GrafanaPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new GrafanaPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -333,41 +384,57 @@ public virtual async Task> GetIfExi } /// - /// Tries to get details for this resource from the service. + /// Get specific private link resource information for this grafana resource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName}. /// /// - /// Operation Id - /// PrivateLinkResource_Get + /// Operation Id. + /// PrivateLinkResources_Get. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// - /// The to use. + /// /// 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 privateLinkResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); - using var scope = _grafanaPrivateLinkResourcePrivateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.GetIfExists"); + using DiagnosticScope scope = _privateLinkResourcesClientDiagnostics.CreateScope("GrafanaPrivateLinkResourceCollection.GetIfExists"); scope.Start(); try { - var response = _grafanaPrivateLinkResourcePrivateLinkResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateLinkResourceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateLinkResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(GrafanaPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((GrafanaPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new GrafanaPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -387,6 +454,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetAll().GetEnumerator(); } + /// The cancellation token to use. IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) { return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResourceData.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResourceData.Serialization.cs index 304ce31788f4..67fd2bd37214 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResourceData.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResourceData.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.Grafana.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.Grafana { - public partial class GrafanaPrivateLinkResourceData : IUtf8JsonSerializable, IJsonModel + /// A private link resource. + public partial class GrafanaPrivateLinkResourceData : 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,180 +33,110 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod /// 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(GrafanaPrivateLinkResourceData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) - { - writer.WritePropertyName("provisioningState"u8); - writer.WriteStringValue(ProvisioningState.Value.ToString()); - } - if (options.Format != "W" && Optional.IsDefined(GroupId)) - { - writer.WritePropertyName("groupId"u8); - writer.WriteStringValue(GroupId); - } - if (options.Format != "W" && Optional.IsCollectionDefined(RequiredMembers)) - { - writer.WritePropertyName("requiredMembers"u8); - writer.WriteStartArray(); - foreach (var item in RequiredMembers) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (Optional.IsCollectionDefined(RequiredZoneNames)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("requiredZoneNames"u8); - writer.WriteStartArray(); - foreach (var item in RequiredZoneNames) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - writer.WriteEndObject(); } - GrafanaPrivateLinkResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaPrivateLinkResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (GrafanaPrivateLinkResourceData)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(GrafanaPrivateLinkResourceData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaPrivateLinkResourceData(document.RootElement, options); } - internal static GrafanaPrivateLinkResourceData DeserializeGrafanaPrivateLinkResourceData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaPrivateLinkResourceData DeserializeGrafanaPrivateLinkResourceData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - ResourceIdentifier id = default; + string id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - GrafanaProvisioningState? provisioningState = default; - string groupId = default; - IReadOnlyList requiredMembers = default; - IList requiredZoneNames = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + GrafanaPrivateLinkResourceProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + id = 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, AzureResourceManagerGrafanaContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerGrafanaContext.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("provisioningState"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new GrafanaProvisioningState(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("groupId"u8)) - { - groupId = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("requiredMembers"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - requiredMembers = array; - continue; - } - if (property0.NameEquals("requiredZoneNames"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - requiredZoneNames = array; - continue; - } - } + properties = GrafanaPrivateLinkResourceProperties.DeserializeGrafanaPrivateLinkResourceProperties(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 GrafanaPrivateLinkResourceData( id, name, - type, + resourceType, systemData, - provisioningState, - groupId, - requiredMembers ?? new ChangeTrackingList(), - requiredZoneNames ?? 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": @@ -214,15 +146,20 @@ BinaryData IPersistableModel.Write(ModelReaderWr } } - GrafanaPrivateLinkResourceData 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. + GrafanaPrivateLinkResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (GrafanaPrivateLinkResourceData)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 DeserializeGrafanaPrivateLinkResourceData(document.RootElement, options); } default: @@ -230,6 +167,14 @@ GrafanaPrivateLinkResourceData IPersistableModel } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static GrafanaPrivateLinkResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGrafanaPrivateLinkResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResourceData.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResourceData.cs index 387208ce0e9d..654d0e034af7 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResourceData.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/GrafanaPrivateLinkResourceData.cs @@ -13,66 +13,44 @@ namespace Azure.ResourceManager.Grafana { - /// - /// A class representing the GrafanaPrivateLinkResource data model. - /// A private link resource - /// + /// A private link resource. public partial class GrafanaPrivateLinkResourceData : 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 . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// Provisioning state of the resource. - /// The private link resource group id. - /// The private link resource required member names. - /// The private link resource Private link DNS zone name. - /// Keeps track of any properties unknown to the library. - internal GrafanaPrivateLinkResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, GrafanaProvisioningState? provisioningState, string groupId, IReadOnlyList requiredMembers, IList requiredZoneNames, 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. + /// Resource properties. + internal GrafanaPrivateLinkResourceData(string id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, GrafanaPrivateLinkResourceProperties properties) : base(id, name, resourceType, systemData) { - ProvisioningState = provisioningState; - GroupId = groupId; - RequiredMembers = requiredMembers; - RequiredZoneNames = requiredZoneNames; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; } + /// Resource properties. + internal GrafanaPrivateLinkResourceProperties Properties { get; } + /// Provisioning state of the resource. - public GrafanaProvisioningState? ProvisioningState { get; } + public GrafanaProvisioningState? ProvisioningState + { + get + { + return Properties.ProvisioningState; + } + } + /// The private link resource group id. - public string GroupId { get; } + public string GroupId + { + get + { + return Properties.GroupId; + } + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/Argument.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/Argument.cs index 234e5c76d1f3..9b9e88f0d67d 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/Argument.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/Argument.cs @@ -11,8 +11,10 @@ namespace Azure.ResourceManager.Grafana { - 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..749b51c5db3b --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/AsyncPageableWrapper.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class AsyncPageableWrapper : AsyncPageable + { + /// The source async pageable value of type AsyncPageable<T>. + private AsyncPageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the AsyncPageableWrapper class. + /// The source async pageable value of type AsyncPageable<T>. + /// The converter function from T to U. + public AsyncPageableWrapper(AsyncPageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from AsyncPageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + await foreach (Page page in _source.AsPages(continuationToken, pageSizeHint).ConfigureAwait(false)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ChangeTrackingDictionary.cs index 2cfb0525d91a..7d778872a338 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ChangeTrackingDictionary.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -11,7 +11,8 @@ namespace Azure.ResourceManager.Grafana { - 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ChangeTrackingList.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ChangeTrackingList.cs index 80a92830f1ba..ccb9795f38e8 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ChangeTrackingList.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ChangeTrackingList.cs @@ -12,7 +12,7 @@ namespace Azure.ResourceManager.Grafana { - 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..cfdc7e3c8785 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/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.Grafana +{ + 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..554ce1f0090d --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/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.Grafana +{ + [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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..723bef33f3fb --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/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.Grafana +{ + [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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..328c3c77d525 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/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.Grafana +{ + [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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..f9902eaf4830 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/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.Grafana +{ + [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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ErrorResult.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..a37873ee55e8 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/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.Grafana +{ + 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ModelSerializationExtensions.cs index a20f8a647cbe..412e705f8ae5 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/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.Grafana { - 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/Optional.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/Optional.cs index f33fa0c696a4..91577892676a 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/Optional.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/Optional.cs @@ -10,7 +10,7 @@ namespace Azure.ResourceManager.Grafana { - 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/PageableWrapper.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..9939fe1e809b --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/PageableWrapper.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class PageableWrapper : Pageable + { + /// The source pageable value of type Pageable<T>. + private Pageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the PageableWrapper class. + /// The source pageable value of type Pageable<T>. + /// The converter function from T to U. + public PageableWrapper(Pageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from Pageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + foreach (Page page in _source.AsPages(continuationToken, pageSizeHint)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..beee512b5756 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/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.Grafana +{ + 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/RequestContextExtensions.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..2bb560413588 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/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.Grafana +{ + 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/SerializationFormat.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..2d809e564764 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/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.Grafana +{ + 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/TypeFormatters.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..3a8f96f8b1bb --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/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.Grafana +{ + 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/Utf8JsonRequestContent.cs index 8741feedfa4c..c5c627c1208d 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/Utf8JsonRequestContent.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -13,7 +13,7 @@ namespace Azure.ResourceManager.Grafana { - 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/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaArmOperation.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaArmOperation.cs index 724e83b5a75b..845f411fa8d9 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaArmOperation.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaArmOperation.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.Grafana { -#pragma warning disable SA1649 // File name should match first type name - internal class GrafanaArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class GrafanaArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected GrafanaArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal GrafanaArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response); @@ -36,12 +37,20 @@ internal GrafanaArmOperation(Response response, RehydrationToken? rehydrationTok _operationId = GetOperationId(rehydrationToken); } + /// + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. internal GrafanaArmOperation(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,48 +58,49 @@ internal GrafanaArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline p _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "GrafanaArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + nextLinkOperation, + clientDiagnostics, + response, + "GrafanaArmOperation", + null, + new SequentialDelayStrategy()); } + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. private string GetOperationId(RehydrationToken? rehydrationToken) { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerGrafanaContext.Default); - using var document = JsonDocument.Parse(data); - var lroDetails = document.RootElement; - return lroDetails.GetProperty("id").GetString(); + return rehydrationToken?.Id; } - /// - public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; - /// + /// public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; - /// - public override bool HasCompleted => _operation.HasCompleted; - - /// + /// public override Response GetRawResponse() => _operation.RawResponse; - /// + /// public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); - /// + /// public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); - /// + /// public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); - /// + /// public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); - /// + /// public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); - /// + /// public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaArmOperationOfT.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaArmOperationOfT.cs index 5cc46b8b7338..9577c35119ed 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaArmOperationOfT.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaArmOperationOfT.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.Grafana { -#pragma warning disable SA1649 // File name should match first type name - internal class GrafanaArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class GrafanaArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected GrafanaArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal GrafanaArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); @@ -36,12 +37,21 @@ internal GrafanaArmOperation(Response response, RehydrationToken? rehydration _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 GrafanaArmOperation(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 GrafanaArmOperation(IOperationSource source, ClientDiagnostics clien _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(NextLinkOperationImplementation.Create(source, nextLinkOperation), clientDiagnostics, response, "GrafanaArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "GrafanaArmOperation", + null, + new SequentialDelayStrategy()); } - private string GetOperationId(RehydrationToken? rehydrationToken) - { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerGrafanaContext.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/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaIntegrationFabricOperationSource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaIntegrationFabricOperationSource.cs index bf935ba1df31..960b7458cfd3 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaIntegrationFabricOperationSource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaIntegrationFabricOperationSource.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.Grafana { - internal class GrafanaIntegrationFabricOperationSource : IOperationSource + /// + internal partial class GrafanaIntegrationFabricOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal GrafanaIntegrationFabricOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// GrafanaIntegrationFabricResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerGrafanaContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + GrafanaIntegrationFabricData data = GrafanaIntegrationFabricData.DeserializeGrafanaIntegrationFabricData(document.RootElement, ModelSerializationExtensions.WireOptions); return new GrafanaIntegrationFabricResource(_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, AzureResourceManagerGrafanaContext.Default); - return await Task.FromResult(new GrafanaIntegrationFabricResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + GrafanaIntegrationFabricData data = GrafanaIntegrationFabricData.DeserializeGrafanaIntegrationFabricData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new GrafanaIntegrationFabricResource(_client, data); } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaPrivateEndpointConnectionOperationSource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaPrivateEndpointConnectionOperationSource.cs index 56d0dbdb81ea..e5a3203e2695 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaPrivateEndpointConnectionOperationSource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/GrafanaPrivateEndpointConnectionOperationSource.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.Grafana { - internal class GrafanaPrivateEndpointConnectionOperationSource : IOperationSource + /// + internal partial class GrafanaPrivateEndpointConnectionOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal GrafanaPrivateEndpointConnectionOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// GrafanaPrivateEndpointConnectionResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerGrafanaContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + GrafanaPrivateEndpointConnectionData data = GrafanaPrivateEndpointConnectionData.DeserializeGrafanaPrivateEndpointConnectionData(document.RootElement, ModelSerializationExtensions.WireOptions); return new GrafanaPrivateEndpointConnectionResource(_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, AzureResourceManagerGrafanaContext.Default); - return await Task.FromResult(new GrafanaPrivateEndpointConnectionResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + GrafanaPrivateEndpointConnectionData data = GrafanaPrivateEndpointConnectionData.DeserializeGrafanaPrivateEndpointConnectionData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new GrafanaPrivateEndpointConnectionResource(_client, data); } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/ManagedDashboardOperationSource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/ManagedDashboardOperationSource.cs index b3f1aad9e479..e82e023e8624 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/ManagedDashboardOperationSource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/ManagedDashboardOperationSource.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.Grafana { - internal class ManagedDashboardOperationSource : IOperationSource + /// + internal partial class ManagedDashboardOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal ManagedDashboardOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// ManagedDashboardResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerGrafanaContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + ManagedDashboardData data = ManagedDashboardData.DeserializeManagedDashboardData(document.RootElement, ModelSerializationExtensions.WireOptions); return new ManagedDashboardResource(_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, AzureResourceManagerGrafanaContext.Default); - return await Task.FromResult(new ManagedDashboardResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + ManagedDashboardData data = ManagedDashboardData.DeserializeManagedDashboardData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new ManagedDashboardResource(_client, data); } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/ManagedGrafanaOperationSource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/ManagedGrafanaOperationSource.cs index 769f49c8dc9d..7b416b0db311 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/ManagedGrafanaOperationSource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/ManagedGrafanaOperationSource.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.Grafana { - internal class ManagedGrafanaOperationSource : IOperationSource + /// + internal partial class ManagedGrafanaOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal ManagedGrafanaOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// ManagedGrafanaResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerGrafanaContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + ManagedGrafanaData data = ManagedGrafanaData.DeserializeManagedGrafanaData(document.RootElement, ModelSerializationExtensions.WireOptions); return new ManagedGrafanaResource(_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, AzureResourceManagerGrafanaContext.Default); - return await Task.FromResult(new ManagedGrafanaResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + ManagedGrafanaData data = ManagedGrafanaData.DeserializeManagedGrafanaData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new ManagedGrafanaResource(_client, data); } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/ManagedPrivateEndpointModelOperationSource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/ManagedPrivateEndpointModelOperationSource.cs index f2435a0dfd0a..68c6ff547f2c 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/ManagedPrivateEndpointModelOperationSource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/LongRunningOperation/ManagedPrivateEndpointModelOperationSource.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.Grafana { - internal class ManagedPrivateEndpointModelOperationSource : IOperationSource + /// + internal partial class ManagedPrivateEndpointModelOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal ManagedPrivateEndpointModelOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// ManagedPrivateEndpointModelResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerGrafanaContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + ManagedPrivateEndpointModelData data = ManagedPrivateEndpointModelData.DeserializeManagedPrivateEndpointModelData(document.RootElement, ModelSerializationExtensions.WireOptions); return new ManagedPrivateEndpointModelResource(_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, AzureResourceManagerGrafanaContext.Default); - return await Task.FromResult(new ManagedPrivateEndpointModelResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + ManagedPrivateEndpointModelData data = ManagedPrivateEndpointModelData.DeserializeManagedPrivateEndpointModelData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new ManagedPrivateEndpointModelResource(_client, data); } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardCollection.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardCollection.cs index 9463fc577ae0..22aa80e5e660 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardCollection.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardCollection.cs @@ -8,12 +8,13 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; 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; namespace Azure.ResourceManager.Grafana @@ -25,73 +26,84 @@ namespace Azure.ResourceManager.Grafana /// public partial class ManagedDashboardCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _managedDashboardClientDiagnostics; - private readonly ManagedDashboardsRestOperations _managedDashboardRestClient; + private readonly ClientDiagnostics _managedDashboardsClientDiagnostics; + private readonly ManagedDashboards _managedDashboardsRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of ManagedDashboardCollection for mocking. protected ManagedDashboardCollection() { } - /// 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 ManagedDashboardCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _managedDashboardClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ManagedDashboardResource.ResourceType.Namespace, Diagnostics); TryGetApiVersion(ManagedDashboardResource.ResourceType, out string managedDashboardApiVersion); - _managedDashboardRestClient = new ManagedDashboardsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedDashboardApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + _managedDashboardsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ManagedDashboardResource.ResourceType.Namespace, Diagnostics); + _managedDashboardsRestClient = new ManagedDashboards(_managedDashboardsClientDiagnostics, Pipeline, Endpoint, managedDashboardApiVersion ?? "2025-09-01-preview"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ResourceGroupResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } } /// /// Create or update a dashboard for grafana resource. This API is idempotent, so user can either create a new dashboard or update an existing dashboard. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Create + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedDashboards_Create. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// The name of the Azure Managed Dashboard. - /// The to use. + /// /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string dashboardName, ManagedDashboardData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardCollection.CreateOrUpdate"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _managedDashboardRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, data, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(new ManagedDashboardOperationSource(Client), _managedDashboardClientDiagnostics, Pipeline, _managedDashboardRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, ManagedDashboardData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + GrafanaArmOperation operation = new GrafanaArmOperation( + new ManagedDashboardOperationSource(Client), + _managedDashboardsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -105,42 +117,51 @@ public virtual async Task> CreateOrUpdate /// Create or update a dashboard for grafana resource. This API is idempotent, so user can either create a new dashboard or update an existing dashboard. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Operation Id - /// ManagedDashboard_Create + /// Operation Id. + /// ManagedDashboards_Create. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// The name of the Azure Managed Dashboard. - /// The to use. + /// /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string dashboardName, ManagedDashboardData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardCollection.CreateOrUpdate"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardCollection.CreateOrUpdate"); scope.Start(); try { - var response = _managedDashboardRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, data, cancellationToken); - var operation = new GrafanaArmOperation(new ManagedDashboardOperationSource(Client), _managedDashboardClientDiagnostics, Pipeline, _managedDashboardRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, ManagedDashboardData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + GrafanaArmOperation operation = new GrafanaArmOperation( + new ManagedDashboardOperationSource(Client), + _managedDashboardsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -154,38 +175,42 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil w /// Get the properties of a specific dashboard for grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedDashboards_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The name of the Azure Managed Dashboard. /// 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 dashboardName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardCollection.Get"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardCollection.Get"); scope.Start(); try { - var response = await _managedDashboardRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -199,38 +224,42 @@ public virtual async Task> GetAsync(string da /// Get the properties of a specific dashboard for grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedDashboards_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The name of the Azure Managed Dashboard. /// 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 dashboardName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardCollection.Get"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardCollection.Get"); scope.Start(); try { - var response = _managedDashboardRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -244,50 +273,44 @@ public virtual Response Get(string dashboardName, Canc /// List all resources of dashboards under the specified resource group. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards. /// /// - /// Operation Id - /// ManagedDashboard_List + /// Operation Id. + /// ManagedDashboards_List. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managedDashboardRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedDashboardRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ManagedDashboardResource(Client, ManagedDashboardData.DeserializeManagedDashboardData(e)), _managedDashboardClientDiagnostics, Pipeline, "ManagedDashboardCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new ManagedDashboardsGetAllAsyncCollectionResultOfT(_managedDashboardsRestClient, Id.SubscriptionId, Id.ResourceGroupName, context), data => new ManagedDashboardResource(Client, data)); } /// /// List all resources of dashboards under the specified resource group. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards - /// - /// - /// Operation Id - /// ManagedDashboard_List + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedDashboards_List. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -295,45 +318,61 @@ public virtual AsyncPageable GetAllAsync(CancellationT /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managedDashboardRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedDashboardRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ManagedDashboardResource(Client, ManagedDashboardData.DeserializeManagedDashboardData(e)), _managedDashboardClientDiagnostics, Pipeline, "ManagedDashboardCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new ManagedDashboardsGetAllCollectionResultOfT(_managedDashboardsRestClient, Id.SubscriptionId, Id.ResourceGroupName, context), data => new ManagedDashboardResource(Client, data)); } /// - /// Checks to see if the resource exists in azure. + /// Get the properties of a specific dashboard for grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Operation Id - /// ManagedDashboard_Get + /// Operation Id. + /// ManagedDashboards_Get. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The name of the Azure Managed Dashboard. /// 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 dashboardName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardCollection.Exists"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardCollection.Exists"); scope.Start(); try { - var response = await _managedDashboardRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedDashboardData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -344,39 +383,53 @@ public virtual async Task> ExistsAsync(string dashboardName, Canc } /// - /// Checks to see if the resource exists in azure. + /// Get the properties of a specific dashboard for grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedDashboards_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The name of the Azure Managed Dashboard. /// 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 dashboardName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardCollection.Exists"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardCollection.Exists"); scope.Start(); try { - var response = _managedDashboardRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedDashboardData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -387,41 +440,57 @@ public virtual Response Exists(string dashboardName, CancellationToken can } /// - /// Tries to get details for this resource from the service. + /// Get the properties of a specific dashboard for grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedDashboards_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The name of the Azure Managed Dashboard. /// 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 dashboardName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardCollection.GetIfExists"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardCollection.GetIfExists"); scope.Start(); try { - var response = await _managedDashboardRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedDashboardData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -432,41 +501,57 @@ public virtual async Task> GetIfExist } /// - /// Tries to get details for this resource from the service. + /// Get the properties of a specific dashboard for grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Operation Id - /// ManagedDashboard_Get + /// Operation Id. + /// ManagedDashboards_Get. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The name of the Azure Managed Dashboard. /// 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 dashboardName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardCollection.GetIfExists"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardCollection.GetIfExists"); scope.Start(); try { - var response = _managedDashboardRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, dashboardName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedDashboardData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -486,6 +571,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetAll().GetEnumerator(); } + /// The cancellation token to use. IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) { return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardData.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardData.Serialization.cs index 82b645100f6c..0030fa2eef90 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardData.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardData.Serialization.cs @@ -10,16 +10,23 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.Grafana.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.Grafana { - public partial class ManagedDashboardData : IUtf8JsonSerializable, IJsonModel + /// The managed dashboard resource type. + public partial class ManagedDashboardData : TrackedResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ManagedDashboardData() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,139 +38,140 @@ 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(ManagedDashboardData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - 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); } - writer.WriteEndObject(); } - ManagedDashboardData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedDashboardData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ManagedDashboardData)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(ManagedDashboardData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedDashboardData(document.RootElement, options); } - internal static ManagedDashboardData DeserializeManagedDashboardData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedDashboardData DeserializeManagedDashboardData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IDictionary tags = default; - AzureLocation location = default; - ResourceIdentifier id = default; + string id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - GrafanaProvisioningState? provisioningState = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + ManagedDashboardProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("tags"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - tags = dictionary; - continue; - } - if (property.NameEquals("location"u8)) - { - location = new AzureLocation(property.Value.GetString()); - continue; - } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + id = 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, AzureResourceManagerGrafanaContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerGrafanaContext.Default); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("tags"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) { - if (property0.NameEquals("provisioningState"u8)) + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new GrafanaProvisioningState(property0.Value.GetString()); - continue; + dictionary.Add(prop0.Name, prop0.Value.GetString()); } } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ManagedDashboardProperties.DeserializeManagedDashboardProperties(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 ManagedDashboardData( id, name, - type, + resourceType, systemData, + additionalBinaryDataProperties, tags ?? new ChangeTrackingDictionary(), location, - provisioningState, - serializedAdditionalRawData); + 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": @@ -173,15 +181,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - ManagedDashboardData 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. + ManagedDashboardData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ManagedDashboardData)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 DeserializeManagedDashboardData(document.RootElement, options); } default: @@ -189,6 +202,26 @@ ManagedDashboardData 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(ManagedDashboardData managedDashboardData) + { + if (managedDashboardData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(managedDashboardData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static ManagedDashboardData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeManagedDashboardData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardData.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardData.cs index 0b04e10c7a44..babb2fde5b67 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardData.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardData.cs @@ -13,71 +13,43 @@ namespace Azure.ResourceManager.Grafana { - /// - /// A class representing the ManagedDashboard data model. - /// The managed dashboard resource type. - /// + /// The managed dashboard resource type. public partial class ManagedDashboardData : TrackedResourceData { - /// - /// 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 location. + /// The geo-location where the resource lives. public ManagedDashboardData(AzureLocation location) : base(location) { } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. - /// Provisioning state of the resource. - /// Keeps track of any properties unknown to the library. - internal ManagedDashboardData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, GrafanaProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// Properties specific to the managed dashboard resource. + internal ManagedDashboardData(string id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, ManagedDashboardProperties properties) : base(id, name, resourceType, systemData, tags, location) { - ProvisioningState = provisioningState; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; } - /// Initializes a new instance of for deserialization. - internal ManagedDashboardData() - { - } + /// Properties specific to the managed dashboard resource. + internal ManagedDashboardProperties Properties { get; set; } /// Provisioning state of the resource. - public GrafanaProvisioningState? ProvisioningState { get; } + public GrafanaProvisioningState? ProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardResource.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardResource.Serialization.cs index 9130914f0c04..6cd536889ae6 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardResource.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.Grafana { + /// public partial class ManagedDashboardResource : IJsonModel { - private static ManagedDashboardData s_dataDeserializationInstance; - private static ManagedDashboardData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new ManagedDashboardData(); + + /// 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); - ManagedDashboardData 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. + ManagedDashboardData 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, AzureResourceManagerGrafanaContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. ManagedDashboardData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerGrafanaContext.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/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardResource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardResource.cs index 59ee61e83295..ed396a3b2f2d 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardResource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedDashboardResource.cs @@ -7,47 +7,37 @@ using System; using System.Collections.Generic; -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.Grafana.Models; using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.Grafana { /// - /// A Class representing a ManagedDashboard 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 GetManagedDashboardResource method. - /// Otherwise you can get one from its parent resource using the GetManagedDashboard method. + /// A class representing a ManagedDashboard 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 GetManagedDashboards method. /// public partial class ManagedDashboardResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The dashboardName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string dashboardName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _managedDashboardClientDiagnostics; - private readonly ManagedDashboardsRestOperations _managedDashboardRestClient; + private readonly ClientDiagnostics _managedDashboardsClientDiagnostics; + private readonly ManagedDashboards _managedDashboardsRestClient; private readonly ManagedDashboardData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Dashboard/dashboards"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of ManagedDashboardResource for mocking. protected ManagedDashboardResource() { } - /// 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 ManagedDashboardResource(ArmClient client, ManagedDashboardData data) : this(client, data.Id) @@ -56,71 +46,92 @@ internal ManagedDashboardResource(ArmClient client, ManagedDashboardData 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 ManagedDashboardResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _managedDashboardClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ResourceType.Namespace, Diagnostics); TryGetApiVersion(ResourceType, out string managedDashboardApiVersion); - _managedDashboardRestClient = new ManagedDashboardsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedDashboardApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + _managedDashboardsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ResourceType.Namespace, Diagnostics); + _managedDashboardsRestClient = new ManagedDashboards(_managedDashboardsClientDiagnostics, Pipeline, Endpoint, managedDashboardApiVersion ?? "2025-09-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 ManagedDashboardData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The dashboardName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string dashboardName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}"; + 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 properties of a specific dashboard for grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Operation Id - /// ManagedDashboard_Get + /// Operation Id. + /// ManagedDashboards_Get. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardResource.Get"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardResource.Get"); scope.Start(); try { - var response = await _managedDashboardRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -134,33 +145,41 @@ public virtual async Task> GetAsync(Cancellat /// Get the properties of a specific dashboard for grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Operation Id - /// ManagedDashboard_Get + /// Operation Id. + /// ManagedDashboards_Get. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardResource.Get"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardResource.Get"); scope.Start(); try { - var response = _managedDashboardRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -171,41 +190,49 @@ public virtual Response Get(CancellationToken cancella } /// - /// Delete a dashboard for Grafana resource. + /// Update a dashboard for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Operation Id - /// ManagedDashboard_Delete + /// Operation Id. + /// ManagedDashboards_Update. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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 cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(ManagedDashboardPatch patch, CancellationToken cancellationToken = default) { - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardResource.Update"); scope.Start(); try { - var response = await _managedDashboardRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var uri = _managedDashboardRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new GrafanaArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, ManagedDashboardPatch.ToRequestContent(patch), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -215,41 +242,49 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell } /// - /// Delete a dashboard for Grafana resource. + /// Update a dashboard for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Operation Id - /// ManagedDashboard_Delete + /// Operation Id. + /// ManagedDashboards_Update. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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 cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual Response Update(ManagedDashboardPatch patch, CancellationToken cancellationToken = default) { - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardResource.Update"); scope.Start(); try { - var response = _managedDashboardRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var uri = _managedDashboardRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new GrafanaArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, ManagedDashboardPatch.ToRequestContent(patch), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -259,39 +294,48 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel } /// - /// Update a dashboard for Grafana resource. + /// Delete a dashboard for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Operation Id - /// ManagedDashboard_Update + /// Operation Id. + /// ManagedDashboards_Delete. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The to use. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(ManagedDashboardPatch patch, CancellationToken cancellationToken = default) + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardResource.Update"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardResource.Delete"); scope.Start(); try { - var response = await _managedDashboardRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + GrafanaArmOperation operation = new GrafanaArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; } catch (Exception e) { @@ -301,39 +345,48 @@ public virtual async Task> UpdateAsync(Manage } /// - /// Update a dashboard for Grafana resource. + /// Delete a dashboard for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}. /// /// - /// Operation Id - /// ManagedDashboard_Update + /// Operation Id. + /// ManagedDashboards_Delete. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The to use. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// The cancellation token to use. - /// is null. - public virtual Response Update(ManagedDashboardPatch patch, CancellationToken cancellationToken = default) + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardResource.Update"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardResource.Delete"); scope.Start(); try { - var response = _managedDashboardRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); - return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + GrafanaArmOperation operation = new GrafanaArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; } catch (Exception e) { @@ -342,27 +395,7 @@ public virtual Response Update(ManagedDashboardPatch p } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -372,29 +405,35 @@ public virtual async Task> AddTagAsync(string Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardResource.AddTag"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardResource.AddTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues[key] = value; - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _managedDashboardRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ManagedDashboardResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); + return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ManagedDashboardPatch(); - foreach (var tag in current.Tags) + ManagedDashboardData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ManagedDashboardPatch patch = new ManagedDashboardPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); - return result; + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -404,27 +443,7 @@ public virtual async Task> AddTagAsync(string } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -434,29 +453,35 @@ public virtual Response AddTag(string key, string valu Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardResource.AddTag"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardResource.AddTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues[key] = value; - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _managedDashboardRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new ManagedDashboardResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); + return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ManagedDashboardPatch(); - foreach (var tag in current.Tags) + ManagedDashboardData current = Get(cancellationToken: cancellationToken).Value.Data; + ManagedDashboardPatch patch = new ManagedDashboardPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = Update(patch, cancellationToken: cancellationToken); - return result; + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -466,54 +491,40 @@ public virtual Response AddTag(string key, string valu } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// The cancellation token to use. /// is null. public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardResource.SetTags"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardResource.SetTags"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.ReplaceWith(tags); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _managedDashboardRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ManagedDashboardResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); + return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ManagedDashboardPatch(); + ManagedDashboardData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ManagedDashboardPatch patch = new ManagedDashboardPatch(); patch.Tags.ReplaceWith(tags); - var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); - return result; + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -523,54 +534,40 @@ public virtual async Task> SetTagsAsync(IDict } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// The cancellation token to use. /// is null. public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardResource.SetTags"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardResource.SetTags"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); - var originalTags = GetTagResource().Get(cancellationToken); + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.ReplaceWith(tags); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _managedDashboardRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new ManagedDashboardResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); + return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ManagedDashboardPatch(); + ManagedDashboardData current = Get(cancellationToken: cancellationToken).Value.Data; + ManagedDashboardPatch patch = new ManagedDashboardPatch(); patch.Tags.ReplaceWith(tags); - var result = Update(patch, cancellationToken: cancellationToken); - return result; + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -580,27 +577,7 @@ public virtual Response SetTags(IDictionary - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -608,29 +585,35 @@ public virtual async Task> RemoveTagAsync(str { Argument.AssertNotNull(key, nameof(key)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardResource.RemoveTag"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardResource.RemoveTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.Remove(key); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _managedDashboardRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ManagedDashboardResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); + return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ManagedDashboardPatch(); - foreach (var tag in current.Tags) + ManagedDashboardData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ManagedDashboardPatch patch = new ManagedDashboardPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); - return result; + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -640,27 +623,7 @@ public virtual async Task> RemoveTagAsync(str } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName} - /// - /// - /// Operation Id - /// ManagedDashboard_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -668,29 +631,35 @@ public virtual Response RemoveTag(string key, Cancella { Argument.AssertNotNull(key, nameof(key)); - using var scope = _managedDashboardClientDiagnostics.CreateScope("ManagedDashboardResource.RemoveTag"); + using DiagnosticScope scope = _managedDashboardsClientDiagnostics.CreateScope("ManagedDashboardResource.RemoveTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.Remove(key); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _managedDashboardRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new ManagedDashboardResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedDashboardsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedDashboardData.FromResponse(result), result); + return Response.FromValue(new ManagedDashboardResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ManagedDashboardPatch(); - foreach (var tag in current.Tags) + ManagedDashboardData current = Get(cancellationToken: cancellationToken).Value.Data; + ManagedDashboardPatch patch = new ManagedDashboardPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = Update(patch, cancellationToken: cancellationToken); - return result; + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -699,5 +668,38 @@ public virtual Response RemoveTag(string key, Cancella throw; } } + + /// Gets a collection of DashboardDefinitions in the . + /// An object representing collection of DashboardDefinitions and their operations over a DashboardDefinitionResource. + public virtual DashboardDefinitionCollection GetDashboardDefinitions() + { + return GetCachedClient(client => new DashboardDefinitionCollection(client, Id)); + } + + /// Get the properties of a specific dashboard definition. + /// The name of the Dashboard Definition. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDashboardDefinitionAsync(string definitionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(definitionName, nameof(definitionName)); + + return await GetDashboardDefinitions().GetAsync(definitionName, cancellationToken).ConfigureAwait(false); + } + + /// Get the properties of a specific dashboard definition. + /// The name of the Dashboard Definition. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDashboardDefinition(string definitionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(definitionName, nameof(definitionName)); + + return GetDashboardDefinitions().Get(definitionName, cancellationToken); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaCollection.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaCollection.cs index b1fbac961aa9..84410e4d2d36 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaCollection.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaCollection.cs @@ -8,12 +8,13 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; 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; namespace Azure.ResourceManager.Grafana @@ -25,73 +26,84 @@ namespace Azure.ResourceManager.Grafana /// public partial class ManagedGrafanaCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _managedGrafanaClientDiagnostics; - private readonly ManagedGrafanasRestOperations _managedGrafanaRestClient; + private readonly ClientDiagnostics _managedGrafanasClientDiagnostics; + private readonly ManagedGrafanas _managedGrafanasRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of ManagedGrafanaCollection for mocking. protected ManagedGrafanaCollection() { } - /// 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 ManagedGrafanaCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _managedGrafanaClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ManagedGrafanaResource.ResourceType.Namespace, Diagnostics); TryGetApiVersion(ManagedGrafanaResource.ResourceType, out string managedGrafanaApiVersion); - _managedGrafanaRestClient = new ManagedGrafanasRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedGrafanaApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + _managedGrafanasClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ManagedGrafanaResource.ResourceType.Namespace, Diagnostics); + _managedGrafanasRestClient = new ManagedGrafanas(_managedGrafanasClientDiagnostics, Pipeline, Endpoint, managedGrafanaApiVersion ?? "2025-09-01-preview"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ResourceGroupResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } } /// /// Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new grafana or update an existing grafana. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Create + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedGrafanas_Create. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// The workspace name of Azure Managed Grafana. - /// The to use. + /// /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string workspaceName, ManagedGrafanaData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaCollection.CreateOrUpdate"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _managedGrafanaRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, data, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(new ManagedGrafanaOperationSource(Client), _managedGrafanaClientDiagnostics, Pipeline, _managedGrafanaRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, ManagedGrafanaData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + GrafanaArmOperation operation = new GrafanaArmOperation( + new ManagedGrafanaOperationSource(Client), + _managedGrafanasClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -105,42 +117,51 @@ public virtual async Task> CreateOrUpdateAs /// Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new grafana or update an existing grafana. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Operation Id - /// ManagedGrafana_Create + /// Operation Id. + /// ManagedGrafanas_Create. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// The workspace name of Azure Managed Grafana. - /// The to use. + /// /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string workspaceName, ManagedGrafanaData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaCollection.CreateOrUpdate"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaCollection.CreateOrUpdate"); scope.Start(); try { - var response = _managedGrafanaRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, data, cancellationToken); - var operation = new GrafanaArmOperation(new ManagedGrafanaOperationSource(Client), _managedGrafanaClientDiagnostics, Pipeline, _managedGrafanaRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, ManagedGrafanaData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + GrafanaArmOperation operation = new GrafanaArmOperation( + new ManagedGrafanaOperationSource(Client), + _managedGrafanasClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -154,38 +175,42 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil wai /// Get the properties of a specific workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedGrafanas_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The workspace name of Azure Managed Grafana. /// 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 workspaceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaCollection.Get"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaCollection.Get"); scope.Start(); try { - var response = await _managedGrafanaRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ManagedGrafanaResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -199,38 +224,42 @@ public virtual async Task> GetAsync(string work /// Get the properties of a specific workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedGrafanas_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The workspace name of Azure Managed Grafana. /// 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 workspaceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaCollection.Get"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaCollection.Get"); scope.Start(); try { - var response = _managedGrafanaRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ManagedGrafanaResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -244,50 +273,44 @@ public virtual Response Get(string workspaceName, Cancel /// List all resources of workspaces for Grafana under the specified resource group. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana. /// /// - /// Operation Id - /// ManagedGrafana_ListByResourceGroup + /// Operation Id. + /// ManagedGrafanas_ListByResourceGroup. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managedGrafanaRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedGrafanaRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ManagedGrafanaResource(Client, ManagedGrafanaData.DeserializeManagedGrafanaData(e)), _managedGrafanaClientDiagnostics, Pipeline, "ManagedGrafanaCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new ManagedGrafanasGetByResourceGroupAsyncCollectionResultOfT(_managedGrafanasRestClient, Id.SubscriptionId, Id.ResourceGroupName, context), data => new ManagedGrafanaResource(Client, data)); } /// /// List all resources of workspaces for Grafana under the specified resource group. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana - /// - /// - /// Operation Id - /// ManagedGrafana_ListByResourceGroup + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedGrafanas_ListByResourceGroup. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -295,45 +318,61 @@ public virtual AsyncPageable GetAllAsync(CancellationTok /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managedGrafanaRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedGrafanaRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ManagedGrafanaResource(Client, ManagedGrafanaData.DeserializeManagedGrafanaData(e)), _managedGrafanaClientDiagnostics, Pipeline, "ManagedGrafanaCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new ManagedGrafanasGetByResourceGroupCollectionResultOfT(_managedGrafanasRestClient, Id.SubscriptionId, Id.ResourceGroupName, context), data => new ManagedGrafanaResource(Client, data)); } /// - /// Checks to see if the resource exists in azure. + /// Get the properties of a specific workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Operation Id - /// ManagedGrafana_Get + /// Operation Id. + /// ManagedGrafanas_Get. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The workspace name of Azure Managed Grafana. /// 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 workspaceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaCollection.Exists"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaCollection.Exists"); scope.Start(); try { - var response = await _managedGrafanaRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedGrafanaData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -344,39 +383,53 @@ public virtual async Task> ExistsAsync(string workspaceName, Canc } /// - /// Checks to see if the resource exists in azure. + /// Get the properties of a specific workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedGrafanas_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The workspace name of Azure Managed Grafana. /// 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 workspaceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaCollection.Exists"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaCollection.Exists"); scope.Start(); try { - var response = _managedGrafanaRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedGrafanaData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -387,41 +440,57 @@ public virtual Response Exists(string workspaceName, CancellationToken can } /// - /// Tries to get details for this resource from the service. + /// Get the properties of a specific workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedGrafanas_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The workspace name of Azure Managed Grafana. /// 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 workspaceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaCollection.GetIfExists"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaCollection.GetIfExists"); scope.Start(); try { - var response = await _managedGrafanaRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedGrafanaData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new ManagedGrafanaResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -432,41 +501,57 @@ public virtual async Task> GetIfExistsA } /// - /// Tries to get details for this resource from the service. + /// Get the properties of a specific workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Operation Id - /// ManagedGrafana_Get + /// Operation Id. + /// ManagedGrafanas_Get. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The workspace name of Azure Managed Grafana. /// 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 workspaceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaCollection.GetIfExists"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaCollection.GetIfExists"); scope.Start(); try { - var response = _managedGrafanaRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, workspaceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedGrafanaData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new ManagedGrafanaResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -486,6 +571,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetAll().GetEnumerator(); } + /// The cancellation token to use. IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) { return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaData.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaData.Serialization.cs index c688671c943d..56c053676de1 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaData.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaData.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.Grafana.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.Grafana { - public partial class ManagedGrafanaData : IUtf8JsonSerializable, IJsonModel + /// The grafana resource type. + public partial class ManagedGrafanaData : 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,12 +33,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// 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(ManagedGrafanaData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Properties)) { @@ -48,139 +49,177 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku, options); } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + } if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireV3Options); + ((IJsonModel)Identity).Write(writer, options); } } - ManagedGrafanaData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedGrafanaData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ManagedGrafanaData)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(ManagedGrafanaData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedGrafanaData(document.RootElement, options); } - internal static ManagedGrafanaData DeserializeManagedGrafanaData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedGrafanaData DeserializeManagedGrafanaData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + string id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); ManagedGrafanaProperties properties = default; ManagedGrafanaSku sku = default; - ManagedServiceIdentity identity = default; IDictionary tags = default; - AzureLocation location = default; - ResourceIdentifier id = default; - string name = default; - ResourceType type = default; - SystemData systemData = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + string location = default; + ManagedServiceIdentity identity = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("id"u8)) + { + id = 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 (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = ManagedGrafanaProperties.DeserializeManagedGrafanaProperties(property.Value, options); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerGrafanaContext.Default); continue; } - if (property.NameEquals("sku"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - sku = ManagedGrafanaSku.DeserializeManagedGrafanaSku(property.Value, options); + properties = ManagedGrafanaProperties.DeserializeManagedGrafanaProperties(prop.Value, options); continue; } - if (property.NameEquals("identity"u8)) + if (prop.NameEquals("sku"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireV3Options, AzureResourceManagerGrafanaContext.Default); + sku = ManagedGrafanaSku.DeserializeManagedGrafanaSku(prop.Value, options); continue; } - if (property.NameEquals("tags"u8)) + if (prop.NameEquals("tags"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()); + } } tags = dictionary; continue; } - if (property.NameEquals("location"u8)) - { - location = new AzureLocation(property.Value.GetString()); - continue; - } - if (property.NameEquals("id"u8)) - { - id = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("location"u8)) { - name = property.Value.GetString(); + location = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("identity"u8)) { - type = new ResourceType(property.Value.GetString()); - continue; - } - if (property.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, AzureResourceManagerGrafanaContext.Default); + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerGrafanaContext.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 ManagedGrafanaData( id, name, - type, + resourceType, systemData, - tags ?? new ChangeTrackingDictionary(), - location, + additionalBinaryDataProperties, properties, sku, - identity, - serializedAdditionalRawData); + tags ?? new ChangeTrackingDictionary(), + location, + identity); } - 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": @@ -190,15 +229,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - ManagedGrafanaData 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. + ManagedGrafanaData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ManagedGrafanaData)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 DeserializeManagedGrafanaData(document.RootElement, options); } default: @@ -206,6 +250,26 @@ ManagedGrafanaData IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ManagedGrafanaData managedGrafanaData) + { + if (managedGrafanaData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(managedGrafanaData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static ManagedGrafanaData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeManagedGrafanaData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaData.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaData.cs index 2e086c5b313c..6bc7dfeabb41 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaData.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaData.cs @@ -13,78 +13,51 @@ namespace Azure.ResourceManager.Grafana { - /// - /// A class representing the ManagedGrafana data model. - /// The grafana resource type. - /// - public partial class ManagedGrafanaData : TrackedResourceData + /// The grafana resource type. + public partial class ManagedGrafanaData : 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 . - /// The location. - public ManagedGrafanaData(AzureLocation location) : base(location) + public ManagedGrafanaData() { + Tags = new ChangeTrackingDictionary(); } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. + /// 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. /// Properties specific to the grafana resource. /// The Sku of the grafana resource. + /// Resource tags. + /// The geo-location where the resource lives. /// The managed service identities assigned to this resource. - /// Keeps track of any properties unknown to the library. - internal ManagedGrafanaData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ManagedGrafanaProperties properties, ManagedGrafanaSku sku, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + internal ManagedGrafanaData(string id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, ManagedGrafanaProperties properties, ManagedGrafanaSku sku, IDictionary tags, string location, ManagedServiceIdentity identity) : base(id, name, resourceType, systemData) { + _additionalBinaryDataProperties = additionalBinaryDataProperties; Properties = properties; Sku = sku; + Tags = tags; + Location = location; Identity = identity; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ManagedGrafanaData() - { } /// Properties specific to the grafana resource. public ManagedGrafanaProperties Properties { get; set; } + /// The Sku of the grafana resource. public ManagedGrafanaSku Sku { get; set; } + + /// Resource tags. + public IDictionary Tags { get; } + + /// The geo-location where the resource lives. + public string Location { get; set; } + /// The managed service identities assigned to this resource. public ManagedServiceIdentity Identity { get; set; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaResource.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaResource.Serialization.cs index db91fbe5a944..626a7e124de9 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaResource.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.Grafana { + /// public partial class ManagedGrafanaResource : IJsonModel { - private static ManagedGrafanaData s_dataDeserializationInstance; - private static ManagedGrafanaData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new ManagedGrafanaData(); + + /// 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); - ManagedGrafanaData 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. + ManagedGrafanaData 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, AzureResourceManagerGrafanaContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. ManagedGrafanaData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerGrafanaContext.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/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaResource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaResource.cs index 897e5356e2e0..3645e9c67564 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaResource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedGrafanaResource.cs @@ -7,48 +7,37 @@ using System; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; 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.Grafana.Models; using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.Grafana { /// - /// A Class representing a ManagedGrafana 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 GetManagedGrafanaResource method. - /// Otherwise you can get one from its parent resource using the GetManagedGrafana method. + /// A class representing a ManagedGrafana 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 GetManagedGrafanas method. /// public partial class ManagedGrafanaResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The workspaceName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _managedGrafanaClientDiagnostics; - private readonly ManagedGrafanasRestOperations _managedGrafanaRestClient; + private readonly ClientDiagnostics _managedGrafanasClientDiagnostics; + private readonly ManagedGrafanas _managedGrafanasRestClient; private readonly ManagedGrafanaData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Dashboard/grafana"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of ManagedGrafanaResource for mocking. protected ManagedGrafanaResource() { } - /// 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 ManagedGrafanaResource(ArmClient client, ManagedGrafanaData data) : this(client, data.Id) @@ -57,347 +46,92 @@ internal ManagedGrafanaResource(ArmClient client, ManagedGrafanaData data) : thi _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 ManagedGrafanaResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _managedGrafanaClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ResourceType.Namespace, Diagnostics); TryGetApiVersion(ResourceType, out string managedGrafanaApiVersion); - _managedGrafanaRestClient = new ManagedGrafanasRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedGrafanaApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + _managedGrafanasClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ResourceType.Namespace, Diagnostics); + _managedGrafanasRestClient = new ManagedGrafanas(_managedGrafanasClientDiagnostics, Pipeline, Endpoint, managedGrafanaApiVersion ?? "2025-09-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 ManagedGrafanaData 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)); - } - - /// Gets a collection of GrafanaPrivateEndpointConnectionResources in the ManagedGrafana. - /// An object representing collection of GrafanaPrivateEndpointConnectionResources and their operations over a GrafanaPrivateEndpointConnectionResource. - public virtual GrafanaPrivateEndpointConnectionCollection GetGrafanaPrivateEndpointConnections() - { - return GetCachedClient(client => new GrafanaPrivateEndpointConnectionCollection(client, Id)); - } - - /// - /// Get private endpoint connections. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The private endpoint connection name of Azure Managed Grafana. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetGrafanaPrivateEndpointConnectionAsync(string privateEndpointConnectionName, CancellationToken cancellationToken = default) - { - return await GetGrafanaPrivateEndpointConnections().GetAsync(privateEndpointConnectionName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get private endpoint connections. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The private endpoint connection name of Azure Managed Grafana. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetGrafanaPrivateEndpointConnection(string privateEndpointConnectionName, CancellationToken cancellationToken = default) - { - return GetGrafanaPrivateEndpointConnections().Get(privateEndpointConnectionName, cancellationToken); - } - - /// Gets a collection of GrafanaPrivateLinkResources in the ManagedGrafana. - /// An object representing collection of GrafanaPrivateLinkResources and their operations over a GrafanaPrivateLinkResource. - public virtual GrafanaPrivateLinkResourceCollection GetGrafanaPrivateLinkResources() - { - return GetCachedClient(client => new GrafanaPrivateLinkResourceCollection(client, Id)); - } - - /// - /// Get specific private link resource information for this grafana resource - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName} - /// - /// - /// Operation Id - /// PrivateLinkResource_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The to use. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetGrafanaPrivateLinkResourceAsync(string privateLinkResourceName, CancellationToken cancellationToken = default) - { - return await GetGrafanaPrivateLinkResources().GetAsync(privateLinkResourceName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get specific private link resource information for this grafana resource - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName} - /// - /// - /// Operation Id - /// PrivateLinkResource_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The to use. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetGrafanaPrivateLinkResource(string privateLinkResourceName, CancellationToken cancellationToken = default) - { - return GetGrafanaPrivateLinkResources().Get(privateLinkResourceName, cancellationToken); - } - - /// Gets a collection of ManagedPrivateEndpointModelResources in the ManagedGrafana. - /// An object representing collection of ManagedPrivateEndpointModelResources and their operations over a ManagedPrivateEndpointModelResource. - public virtual ManagedPrivateEndpointModelCollection GetManagedPrivateEndpointModels() - { - return GetCachedClient(client => new ManagedPrivateEndpointModelCollection(client, Id)); - } - - /// - /// Get a specific managed private endpoint of a grafana resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The managed private endpoint name of Azure Managed Grafana. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetManagedPrivateEndpointModelAsync(string managedPrivateEndpointName, CancellationToken cancellationToken = default) - { - return await GetManagedPrivateEndpointModels().GetAsync(managedPrivateEndpointName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get a specific managed private endpoint of a grafana resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The managed private endpoint name of Azure Managed Grafana. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetManagedPrivateEndpointModel(string managedPrivateEndpointName, CancellationToken cancellationToken = default) - { - return GetManagedPrivateEndpointModels().Get(managedPrivateEndpointName, cancellationToken); - } - - /// Gets a collection of GrafanaIntegrationFabricResources in the ManagedGrafana. - /// An object representing collection of GrafanaIntegrationFabricResources and their operations over a GrafanaIntegrationFabricResource. - public virtual GrafanaIntegrationFabricCollection GetGrafanaIntegrationFabrics() - { - return GetCachedClient(client => new GrafanaIntegrationFabricCollection(client, Id)); - } - - /// - /// Get a IntegrationFabric - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} - /// - /// - /// Operation Id - /// IntegrationFabric_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The integration fabric name of Azure Managed Grafana. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetGrafanaIntegrationFabricAsync(string integrationFabricName, CancellationToken cancellationToken = default) + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The workspaceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName) { - return await GetGrafanaIntegrationFabrics().GetAsync(integrationFabricName, cancellationToken).ConfigureAwait(false); + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}"; + return new ResourceIdentifier(resourceId); } - /// - /// Get a IntegrationFabric - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName} - /// - /// - /// Operation Id - /// IntegrationFabric_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The integration fabric name of Azure Managed Grafana. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetGrafanaIntegrationFabric(string integrationFabricName, CancellationToken cancellationToken = default) + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) { - return GetGrafanaIntegrationFabrics().Get(integrationFabricName, cancellationToken); + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Get the properties of a specific workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Operation Id - /// ManagedGrafana_Get + /// Operation Id. + /// ManagedGrafanas_Get. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.Get"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.Get"); scope.Start(); try { - var response = await _managedGrafanaRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ManagedGrafanaResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -411,33 +145,41 @@ public virtual async Task> GetAsync(Cancellatio /// Get the properties of a specific workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Operation Id - /// ManagedGrafana_Get + /// Operation Id. + /// ManagedGrafanas_Get. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.Get"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.Get"); scope.Start(); try { - var response = _managedGrafanaRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ManagedGrafanaResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -448,38 +190,55 @@ public virtual Response Get(CancellationToken cancellati } /// - /// Delete a workspace for Grafana resource. + /// Update a workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Operation Id - /// ManagedGrafana_Delete + /// Operation Id. + /// ManagedGrafanas_Update. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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 cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, ManagedGrafanaPatch patch, CancellationToken cancellationToken = default) { - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.Update"); scope.Start(); try { - var response = await _managedGrafanaRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(_managedGrafanaClientDiagnostics, Pipeline, _managedGrafanaRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, ManagedGrafanaPatch.ToRequestContent(patch), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + GrafanaArmOperation operation = new GrafanaArmOperation( + new ManagedGrafanaOperationSource(Client), + _managedGrafanasClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -490,38 +249,55 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell } /// - /// Delete a workspace for Grafana resource. + /// Update a workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Operation Id - /// ManagedGrafana_Delete + /// Operation Id. + /// ManagedGrafanas_Update. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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 cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, ManagedGrafanaPatch patch, CancellationToken cancellationToken = default) { - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.Update"); scope.Start(); try { - var response = _managedGrafanaRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var operation = new GrafanaArmOperation(_managedGrafanaClientDiagnostics, Pipeline, _managedGrafanaRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, ManagedGrafanaPatch.ToRequestContent(patch), context); + Response response = Pipeline.ProcessMessage(message, context); + GrafanaArmOperation operation = new GrafanaArmOperation( + new ManagedGrafanaOperationSource(Client), + _managedGrafanasClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); + { + operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -532,42 +308,45 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel } /// - /// Update a workspace for Grafana resource. + /// Delete a workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Operation Id - /// ManagedGrafana_Update + /// Operation Id. + /// ManagedGrafanas_Delete. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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 to use. /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, ManagedGrafanaPatch patch, CancellationToken cancellationToken = default) + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.Update"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.Delete"); scope.Start(); try { - var response = await _managedGrafanaRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(new ManagedGrafanaOperationSource(Client), _managedGrafanaClientDiagnostics, Pipeline, _managedGrafanaRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + GrafanaArmOperation operation = new GrafanaArmOperation(_managedGrafanasClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -578,42 +357,45 @@ public virtual async Task> UpdateAsync(Wait } /// - /// Update a workspace for Grafana resource. + /// Delete a workspace for Grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}. /// /// - /// Operation Id - /// ManagedGrafana_Update + /// Operation Id. + /// ManagedGrafanas_Delete. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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 to use. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, ManagedGrafanaPatch patch, CancellationToken cancellationToken = default) + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.Update"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.Delete"); scope.Start(); try { - var response = _managedGrafanaRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); - var operation = new GrafanaArmOperation(new ManagedGrafanaOperationSource(Client), _managedGrafanaClientDiagnostics, Pipeline, _managedGrafanaRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + GrafanaArmOperation operation = new GrafanaArmOperation(_managedGrafanasClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); + { + operation.WaitForCompletionResponse(cancellationToken); + } return operation; } catch (Exception e) @@ -627,31 +409,41 @@ public virtual ArmOperation Update(WaitUntil waitUntil, /// Retrieve enterprise add-on details information /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/checkEnterpriseDetails + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/checkEnterpriseDetails. /// /// - /// Operation Id - /// ManagedGrafanas_CheckEnterpriseDetails + /// Operation Id. + /// ManagedGrafanas_CheckEnterpriseDetails. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> CheckEnterpriseDetailsAsync(CancellationToken cancellationToken = default) { - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.CheckEnterpriseDetails"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.CheckEnterpriseDetails"); scope.Start(); try { - var response = await _managedGrafanaRestClient.CheckEnterpriseDetailsAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateCheckEnterpriseDetailsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EnterpriseDetails.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -665,31 +457,41 @@ public virtual async Task> CheckEnterpriseDetailsAsy /// Retrieve enterprise add-on details information /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/checkEnterpriseDetails + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/checkEnterpriseDetails. /// /// - /// Operation Id - /// ManagedGrafanas_CheckEnterpriseDetails + /// Operation Id. + /// ManagedGrafanas_CheckEnterpriseDetails. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response CheckEnterpriseDetails(CancellationToken cancellationToken = default) { - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.CheckEnterpriseDetails"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.CheckEnterpriseDetails"); scope.Start(); try { - var response = _managedGrafanaRestClient.CheckEnterpriseDetails(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateCheckEnterpriseDetailsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EnterpriseDetails.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -703,78 +505,116 @@ public virtual Response CheckEnterpriseDetails(CancellationTo /// A synchronous resource action. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/fetchAvailablePlugins + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/fetchAvailablePlugins. /// /// - /// Operation Id - /// ManagedGrafanas_FetchAvailablePlugins + /// Operation Id. + /// ManagedGrafanas_FetchAvailablePlugins. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable FetchAvailablePluginsAsync(CancellationToken cancellationToken = default) + public virtual async Task> FetchAvailablePluginsAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managedGrafanaRestClient.CreateFetchAvailablePluginsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => GrafanaAvailablePlugin.DeserializeGrafanaAvailablePlugin(e), _managedGrafanaClientDiagnostics, Pipeline, "ManagedGrafanaResource.FetchAvailablePlugins", "value", null, cancellationToken); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.FetchAvailablePlugins"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateFetchAvailablePluginsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(GrafanaAvailablePluginListResponse.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// /// A synchronous resource action. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/fetchAvailablePlugins + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/fetchAvailablePlugins. /// /// - /// Operation Id - /// ManagedGrafanas_FetchAvailablePlugins + /// Operation Id. + /// ManagedGrafanas_FetchAvailablePlugins. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable FetchAvailablePlugins(CancellationToken cancellationToken = default) + public virtual Response FetchAvailablePlugins(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managedGrafanaRestClient.CreateFetchAvailablePluginsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => GrafanaAvailablePlugin.DeserializeGrafanaAvailablePlugin(e), _managedGrafanaClientDiagnostics, Pipeline, "ManagedGrafanaResource.FetchAvailablePlugins", "value", null, cancellationToken); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.FetchAvailablePlugins"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateFetchAvailablePluginsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(GrafanaAvailablePluginListResponse.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// /// Refresh and sync managed private endpoints of a grafana resource to latest state. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/refreshManagedPrivateEndpoints + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/refreshManagedPrivateEndpoints. /// /// - /// Operation Id - /// ManagedGrafanas_RefreshManagedPrivateEndpoint + /// Operation Id. + /// ManagedGrafanas_Refresh. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -782,14 +622,21 @@ public virtual Pageable FetchAvailablePlugins(Cancellati /// The cancellation token to use. public virtual async Task RefreshManagedPrivateEndpointAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.RefreshManagedPrivateEndpoint"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.RefreshManagedPrivateEndpoint"); scope.Start(); try { - var response = await _managedGrafanaRestClient.RefreshManagedPrivateEndpointAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(_managedGrafanaClientDiagnostics, Pipeline, _managedGrafanaRestClient.CreateRefreshManagedPrivateEndpointRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateRefreshManagedPrivateEndpointRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + GrafanaArmOperation operation = new GrafanaArmOperation(_managedGrafanasClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -803,20 +650,20 @@ public virtual async Task RefreshManagedPrivateEndpointAsync(WaitU /// Refresh and sync managed private endpoints of a grafana resource to latest state. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/refreshManagedPrivateEndpoints + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/refreshManagedPrivateEndpoints. /// /// - /// Operation Id - /// ManagedGrafanas_RefreshManagedPrivateEndpoint + /// Operation Id. + /// ManagedGrafanas_Refresh. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -824,14 +671,21 @@ public virtual async Task RefreshManagedPrivateEndpointAsync(WaitU /// The cancellation token to use. public virtual ArmOperation RefreshManagedPrivateEndpoint(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.RefreshManagedPrivateEndpoint"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.RefreshManagedPrivateEndpoint"); scope.Start(); try { - var response = _managedGrafanaRestClient.RefreshManagedPrivateEndpoint(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var operation = new GrafanaArmOperation(_managedGrafanaClientDiagnostics, Pipeline, _managedGrafanaRestClient.CreateRefreshManagedPrivateEndpointRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateRefreshManagedPrivateEndpointRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + GrafanaArmOperation operation = new GrafanaArmOperation(_managedGrafanasClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletionResponse(cancellationToken); + } return operation; } catch (Exception e) @@ -841,27 +695,7 @@ public virtual ArmOperation RefreshManagedPrivateEndpoint(WaitUntil waitUntil, C } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -871,28 +705,34 @@ public virtual async Task> AddTagAsync(string k Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.AddTag"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.AddTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues[key] = value; - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _managedGrafanaRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ManagedGrafanaResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); + return Response.FromValue(new ManagedGrafanaResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ManagedGrafanaPatch(); - foreach (var tag in current.Tags) + ManagedGrafanaData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ManagedGrafanaPatch patch = new ManagedGrafanaPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -903,27 +743,7 @@ public virtual async Task> AddTagAsync(string k } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -933,28 +753,34 @@ public virtual Response AddTag(string key, string value, Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.AddTag"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.AddTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues[key] = value; - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _managedGrafanaRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new ManagedGrafanaResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); + return Response.FromValue(new ManagedGrafanaResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ManagedGrafanaPatch(); - foreach (var tag in current.Tags) + ManagedGrafanaData current = Get(cancellationToken: cancellationToken).Value.Data; + ManagedGrafanaPatch patch = new ManagedGrafanaPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -965,53 +791,39 @@ public virtual Response AddTag(string key, string value, } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// The cancellation token to use. /// is null. public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.SetTags"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.SetTags"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.ReplaceWith(tags); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _managedGrafanaRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ManagedGrafanaResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); + return Response.FromValue(new ManagedGrafanaResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ManagedGrafanaPatch(); + ManagedGrafanaData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ManagedGrafanaPatch patch = new ManagedGrafanaPatch(); patch.Tags.ReplaceWith(tags); - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -1022,53 +834,39 @@ public virtual async Task> SetTagsAsync(IDictio } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// The cancellation token to use. /// is null. public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.SetTags"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.SetTags"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); - var originalTags = GetTagResource().Get(cancellationToken); + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.ReplaceWith(tags); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _managedGrafanaRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new ManagedGrafanaResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); + return Response.FromValue(new ManagedGrafanaResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ManagedGrafanaPatch(); + ManagedGrafanaData current = Get(cancellationToken: cancellationToken).Value.Data; + ManagedGrafanaPatch patch = new ManagedGrafanaPatch(); patch.Tags.ReplaceWith(tags); - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -1079,27 +877,7 @@ public virtual Response SetTags(IDictionary - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -1107,28 +885,34 @@ public virtual async Task> RemoveTagAsync(strin { Argument.AssertNotNull(key, nameof(key)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.RemoveTag"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.RemoveTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.Remove(key); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _managedGrafanaRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ManagedGrafanaResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); + return Response.FromValue(new ManagedGrafanaResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ManagedGrafanaPatch(); - foreach (var tag in current.Tags) + ManagedGrafanaData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ManagedGrafanaPatch patch = new ManagedGrafanaPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -1139,27 +923,7 @@ public virtual async Task> RemoveTagAsync(strin } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName} - /// - /// - /// Operation Id - /// ManagedGrafana_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -1167,28 +931,34 @@ public virtual Response RemoveTag(string key, Cancellati { Argument.AssertNotNull(key, nameof(key)); - using var scope = _managedGrafanaClientDiagnostics.CreateScope("ManagedGrafanaResource.RemoveTag"); + using DiagnosticScope scope = _managedGrafanasClientDiagnostics.CreateScope("ManagedGrafanaResource.RemoveTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.Remove(key); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _managedGrafanaRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new ManagedGrafanaResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedGrafanasRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedGrafanaData.FromResponse(result), result); + return Response.FromValue(new ManagedGrafanaResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ManagedGrafanaPatch(); - foreach (var tag in current.Tags) + ManagedGrafanaData current = Get(cancellationToken: cancellationToken).Value.Data; + ManagedGrafanaPatch patch = new ManagedGrafanaPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -1198,5 +968,137 @@ public virtual Response RemoveTag(string key, Cancellati throw; } } + + /// Gets a collection of GrafanaPrivateEndpointConnections in the . + /// An object representing collection of GrafanaPrivateEndpointConnections and their operations over a GrafanaPrivateEndpointConnectionResource. + public virtual GrafanaPrivateEndpointConnectionCollection GetGrafanaPrivateEndpointConnections() + { + return GetCachedClient(client => new GrafanaPrivateEndpointConnectionCollection(client, Id)); + } + + /// Get private endpoint connections. + /// The private endpoint connection name of Azure Managed Grafana. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetGrafanaPrivateEndpointConnectionAsync(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + return await GetGrafanaPrivateEndpointConnections().GetAsync(privateEndpointConnectionName, cancellationToken).ConfigureAwait(false); + } + + /// Get private endpoint connections. + /// The private endpoint connection name of Azure Managed Grafana. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetGrafanaPrivateEndpointConnection(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + return GetGrafanaPrivateEndpointConnections().Get(privateEndpointConnectionName, cancellationToken); + } + + /// Gets a collection of GrafanaPrivateLinkResources in the . + /// An object representing collection of GrafanaPrivateLinkResources and their operations over a GrafanaPrivateLinkResource. + public virtual GrafanaPrivateLinkResourceCollection GetGrafanaPrivateLinkResources() + { + return GetCachedClient(client => new GrafanaPrivateLinkResourceCollection(client, Id)); + } + + /// Get specific private link resource information for this grafana resource. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetGrafanaPrivateLinkResourceAsync(string privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + return await GetGrafanaPrivateLinkResources().GetAsync(privateLinkResourceName, cancellationToken).ConfigureAwait(false); + } + + /// Get specific private link resource information for this grafana resource. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetGrafanaPrivateLinkResource(string privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + return GetGrafanaPrivateLinkResources().Get(privateLinkResourceName, cancellationToken); + } + + /// Gets a collection of ManagedPrivateEndpointModels in the . + /// An object representing collection of ManagedPrivateEndpointModels and their operations over a ManagedPrivateEndpointModelResource. + public virtual ManagedPrivateEndpointModelCollection GetManagedPrivateEndpointModels() + { + return GetCachedClient(client => new ManagedPrivateEndpointModelCollection(client, Id)); + } + + /// Get a specific managed private endpoint of a grafana resource. + /// The managed private endpoint name of Azure Managed Grafana. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetManagedPrivateEndpointModelAsync(string managedPrivateEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); + + return await GetManagedPrivateEndpointModels().GetAsync(managedPrivateEndpointName, cancellationToken).ConfigureAwait(false); + } + + /// Get a specific managed private endpoint of a grafana resource. + /// The managed private endpoint name of Azure Managed Grafana. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetManagedPrivateEndpointModel(string managedPrivateEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); + + return GetManagedPrivateEndpointModels().Get(managedPrivateEndpointName, cancellationToken); + } + + /// Gets a collection of GrafanaIntegrationFabrics in the . + /// An object representing collection of GrafanaIntegrationFabrics and their operations over a GrafanaIntegrationFabricResource. + public virtual GrafanaIntegrationFabricCollection GetGrafanaIntegrationFabrics() + { + return GetCachedClient(client => new GrafanaIntegrationFabricCollection(client, Id)); + } + + /// Get a IntegrationFabric. + /// The integration fabric name of Azure Managed Grafana. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetGrafanaIntegrationFabricAsync(string integrationFabricName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); + + return await GetGrafanaIntegrationFabrics().GetAsync(integrationFabricName, cancellationToken).ConfigureAwait(false); + } + + /// Get a IntegrationFabric. + /// The integration fabric name of Azure Managed Grafana. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetGrafanaIntegrationFabric(string integrationFabricName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); + + return GetGrafanaIntegrationFabrics().Get(integrationFabricName, cancellationToken); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelCollection.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelCollection.cs index 919c620a04a0..147d628df152 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelCollection.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelCollection.cs @@ -8,12 +8,13 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.Grafana { @@ -24,51 +25,49 @@ namespace Azure.ResourceManager.Grafana /// public partial class ManagedPrivateEndpointModelCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _managedPrivateEndpointModelClientDiagnostics; - private readonly ManagedPrivateEndpointModelsRestOperations _managedPrivateEndpointModelRestClient; + private readonly ClientDiagnostics _managedPrivateEndpointModelsClientDiagnostics; + private readonly ManagedPrivateEndpointModels _managedPrivateEndpointModelsRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of ManagedPrivateEndpointModelCollection for mocking. protected ManagedPrivateEndpointModelCollection() { } - /// 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 ManagedPrivateEndpointModelCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _managedPrivateEndpointModelClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ManagedPrivateEndpointModelResource.ResourceType.Namespace, Diagnostics); TryGetApiVersion(ManagedPrivateEndpointModelResource.ResourceType, out string managedPrivateEndpointModelApiVersion); - _managedPrivateEndpointModelRestClient = new ManagedPrivateEndpointModelsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedPrivateEndpointModelApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + _managedPrivateEndpointModelsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ManagedPrivateEndpointModelResource.ResourceType.Namespace, Diagnostics); + _managedPrivateEndpointModelsRestClient = new ManagedPrivateEndpointModels(_managedPrivateEndpointModelsClientDiagnostics, Pipeline, Endpoint, managedPrivateEndpointModelApiVersion ?? "2025-09-01-preview"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ManagedGrafanaResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagedGrafanaResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ManagedGrafanaResource.ResourceType), id); + } } /// /// Create or update a managed private endpoint for a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_Create + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedPrivateEndpointModels_Create. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -76,21 +75,34 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// The managed private endpoint name of Azure Managed Grafana. /// The managed private endpoint to be created or updated. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string managedPrivateEndpointName, ManagedPrivateEndpointModelData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.CreateOrUpdate"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _managedPrivateEndpointModelRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, data, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(new ManagedPrivateEndpointModelOperationSource(Client), _managedPrivateEndpointModelClientDiagnostics, Pipeline, _managedPrivateEndpointModelRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, data).Request, response, OperationFinalStateVia.OriginalUri); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, ManagedPrivateEndpointModelData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + GrafanaArmOperation operation = new GrafanaArmOperation( + new ManagedPrivateEndpointModelOperationSource(Client), + _managedPrivateEndpointModelsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.OriginalUri); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -104,20 +116,16 @@ public virtual async Task> Cre /// Create or update a managed private endpoint for a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Operation Id - /// ManagedPrivateEndpointModel_Create + /// Operation Id. + /// ManagedPrivateEndpointModels_Create. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -125,21 +133,34 @@ public virtual async Task> Cre /// The managed private endpoint name of Azure Managed Grafana. /// The managed private endpoint to be created or updated. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string managedPrivateEndpointName, ManagedPrivateEndpointModelData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.CreateOrUpdate"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.CreateOrUpdate"); scope.Start(); try { - var response = _managedPrivateEndpointModelRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, data, cancellationToken); - var operation = new GrafanaArmOperation(new ManagedPrivateEndpointModelOperationSource(Client), _managedPrivateEndpointModelClientDiagnostics, Pipeline, _managedPrivateEndpointModelRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, data).Request, response, OperationFinalStateVia.OriginalUri); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, ManagedPrivateEndpointModelData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + GrafanaArmOperation operation = new GrafanaArmOperation( + new ManagedPrivateEndpointModelOperationSource(Client), + _managedPrivateEndpointModelsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.OriginalUri); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -153,38 +174,42 @@ public virtual ArmOperation CreateOrUpdate( /// Get a specific managed private endpoint of a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedPrivateEndpointModels_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The managed private endpoint name of Azure Managed Grafana. /// 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 managedPrivateEndpointName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.Get"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.Get"); scope.Start(); try { - var response = await _managedPrivateEndpointModelRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -198,38 +223,42 @@ public virtual async Task> GetAsyn /// Get a specific managed private endpoint of a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedPrivateEndpointModels_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The managed private endpoint name of Azure Managed Grafana. /// 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 managedPrivateEndpointName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.Get"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.Get"); scope.Start(); try { - var response = _managedPrivateEndpointModelRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -243,50 +272,44 @@ public virtual Response Get(string managedP /// List all managed private endpoints of a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints. /// /// - /// Operation Id - /// ManagedPrivateEndpointModel_List + /// Operation Id. + /// ManagedPrivateEndpointModels_List. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managedPrivateEndpointModelRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedPrivateEndpointModelRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ManagedPrivateEndpointModelResource(Client, ManagedPrivateEndpointModelData.DeserializeManagedPrivateEndpointModelData(e)), _managedPrivateEndpointModelClientDiagnostics, Pipeline, "ManagedPrivateEndpointModelCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new ManagedPrivateEndpointModelsGetAllAsyncCollectionResultOfT(_managedPrivateEndpointModelsRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new ManagedPrivateEndpointModelResource(Client, data)); } /// /// List all managed private endpoints of a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_List + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedPrivateEndpointModels_List. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// @@ -294,45 +317,61 @@ public virtual AsyncPageable GetAllAsync(Ca /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managedPrivateEndpointModelRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedPrivateEndpointModelRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ManagedPrivateEndpointModelResource(Client, ManagedPrivateEndpointModelData.DeserializeManagedPrivateEndpointModelData(e)), _managedPrivateEndpointModelClientDiagnostics, Pipeline, "ManagedPrivateEndpointModelCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new ManagedPrivateEndpointModelsGetAllCollectionResultOfT(_managedPrivateEndpointModelsRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new ManagedPrivateEndpointModelResource(Client, data)); } /// - /// Checks to see if the resource exists in azure. + /// Get a specific managed private endpoint of a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get + /// Operation Id. + /// ManagedPrivateEndpointModels_Get. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The managed private endpoint name of Azure Managed Grafana. /// 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 managedPrivateEndpointName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.Exists"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.Exists"); scope.Start(); try { - var response = await _managedPrivateEndpointModelRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedPrivateEndpointModelData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -343,39 +382,53 @@ public virtual async Task> ExistsAsync(string managedPrivateEndpo } /// - /// Checks to see if the resource exists in azure. + /// Get a specific managed private endpoint of a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedPrivateEndpointModels_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The managed private endpoint name of Azure Managed Grafana. /// 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 managedPrivateEndpointName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.Exists"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.Exists"); scope.Start(); try { - var response = _managedPrivateEndpointModelRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedPrivateEndpointModelData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -386,41 +439,57 @@ public virtual Response Exists(string managedPrivateEndpointName, Cancella } /// - /// Tries to get details for this resource from the service. + /// Get a specific managed private endpoint of a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Default Api Version - /// 2025-08-01 + /// Operation Id. + /// ManagedPrivateEndpointModels_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The managed private endpoint name of Azure Managed Grafana. /// 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 managedPrivateEndpointName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.GetIfExists"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.GetIfExists"); scope.Start(); try { - var response = await _managedPrivateEndpointModelRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedPrivateEndpointModelData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -431,41 +500,57 @@ public virtual async Task> } /// - /// Tries to get details for this resource from the service. + /// Get a specific managed private endpoint of a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get + /// Operation Id. + /// ManagedPrivateEndpointModels_Get. /// /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-09-01-preview. /// /// /// /// The managed private endpoint name of Azure Managed Grafana. /// 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 managedPrivateEndpointName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.GetIfExists"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelCollection.GetIfExists"); scope.Start(); try { - var response = _managedPrivateEndpointModelRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, managedPrivateEndpointName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedPrivateEndpointModelData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -485,6 +570,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetAll().GetEnumerator(); } + /// The cancellation token to use. IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) { return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelData.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelData.Serialization.cs index 4eb461f9548f..deac06fa4a5e 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelData.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelData.Serialization.cs @@ -10,16 +10,23 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.Grafana.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.Grafana { - public partial class ManagedPrivateEndpointModelData : IUtf8JsonSerializable, IJsonModel + /// The managed private endpoint resource type. + public partial class ManagedPrivateEndpointModelData : TrackedResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ManagedPrivateEndpointModelData() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,249 +38,140 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo /// 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(ManagedPrivateEndpointModelData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - 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 (Optional.IsDefined(PrivateLinkResourceId)) - { - writer.WritePropertyName("privateLinkResourceId"u8); - writer.WriteStringValue(PrivateLinkResourceId); - } - if (Optional.IsDefined(PrivateLinkResourceRegion)) - { - writer.WritePropertyName("privateLinkResourceRegion"u8); - writer.WriteStringValue(PrivateLinkResourceRegion); - } - if (Optional.IsCollectionDefined(GroupIds)) - { - writer.WritePropertyName("groupIds"u8); - writer.WriteStartArray(); - foreach (var item in GroupIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(RequestMessage)) - { - writer.WritePropertyName("requestMessage"u8); - writer.WriteStringValue(RequestMessage); - } - if (options.Format != "W" && Optional.IsDefined(ConnectionState)) - { - writer.WritePropertyName("connectionState"u8); - writer.WriteObjectValue(ConnectionState, options); - } - if (Optional.IsDefined(PrivateLinkServiceUri)) - { - writer.WritePropertyName("privateLinkServiceUrl"u8); - writer.WriteStringValue(PrivateLinkServiceUri.AbsoluteUri); - } - if (options.Format != "W" && Optional.IsDefined(PrivateLinkServicePrivateIP)) - { - writer.WritePropertyName("privateLinkServicePrivateIP"u8); - writer.WriteStringValue(PrivateLinkServicePrivateIP); - } - writer.WriteEndObject(); } - ManagedPrivateEndpointModelData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedPrivateEndpointModelData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ManagedPrivateEndpointModelData)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(ManagedPrivateEndpointModelData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedPrivateEndpointModelData(document.RootElement, options); } - internal static ManagedPrivateEndpointModelData DeserializeManagedPrivateEndpointModelData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedPrivateEndpointModelData DeserializeManagedPrivateEndpointModelData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IDictionary tags = default; - AzureLocation location = default; - ResourceIdentifier id = default; + string id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - GrafanaProvisioningState? provisioningState = default; - ResourceIdentifier privateLinkResourceId = default; - string privateLinkResourceRegion = default; - IList groupIds = default; - string requestMessage = default; - ManagedPrivateEndpointConnectionState connectionState = default; - Uri privateLinkServiceUrl = default; - string privateLinkServicePrivateIP = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + ManagedPrivateEndpointModelProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("tags"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - tags = dictionary; - continue; - } - if (property.NameEquals("location"u8)) - { - location = new AzureLocation(property.Value.GetString()); - continue; - } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + id = 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, AzureResourceManagerGrafanaContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerGrafanaContext.Default); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("tags"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) { - if (property0.NameEquals("provisioningState"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new GrafanaProvisioningState(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("privateLinkResourceId"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - privateLinkResourceId = new ResourceIdentifier(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("privateLinkResourceRegion"u8)) + if (prop0.Value.ValueKind == JsonValueKind.Null) { - privateLinkResourceRegion = property0.Value.GetString(); - continue; + dictionary.Add(prop0.Name, null); } - if (property0.NameEquals("groupIds"u8)) + else { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - groupIds = array; - continue; - } - if (property0.NameEquals("requestMessage"u8)) - { - requestMessage = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("connectionState"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - connectionState = ManagedPrivateEndpointConnectionState.DeserializeManagedPrivateEndpointConnectionState(property0.Value, options); - continue; - } - if (property0.NameEquals("privateLinkServiceUrl"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - privateLinkServiceUrl = new Uri(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("privateLinkServicePrivateIP"u8)) - { - privateLinkServicePrivateIP = property0.Value.GetString(); - continue; + dictionary.Add(prop0.Name, prop0.Value.GetString()); } } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ManagedPrivateEndpointModelProperties.DeserializeManagedPrivateEndpointModelProperties(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 ManagedPrivateEndpointModelData( id, name, - type, + resourceType, systemData, + additionalBinaryDataProperties, tags ?? new ChangeTrackingDictionary(), location, - provisioningState, - privateLinkResourceId, - privateLinkResourceRegion, - groupIds ?? new ChangeTrackingList(), - requestMessage, - connectionState, - privateLinkServiceUrl, - privateLinkServicePrivateIP, - serializedAdditionalRawData); + 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": @@ -283,15 +181,20 @@ BinaryData IPersistableModel.Write(ModelReaderW } } - ManagedPrivateEndpointModelData 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. + ManagedPrivateEndpointModelData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ManagedPrivateEndpointModelData)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 DeserializeManagedPrivateEndpointModelData(document.RootElement, options); } default: @@ -299,6 +202,26 @@ ManagedPrivateEndpointModelData IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ManagedPrivateEndpointModelData managedPrivateEndpointModelData) + { + if (managedPrivateEndpointModelData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(managedPrivateEndpointModelData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static ManagedPrivateEndpointModelData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeManagedPrivateEndpointModelData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelData.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelData.cs index 32420495f8b5..dd5afbf84b18 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelData.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelData.cs @@ -13,100 +13,142 @@ namespace Azure.ResourceManager.Grafana { - /// - /// A class representing the ManagedPrivateEndpointModel data model. - /// The managed private endpoint resource type. - /// + /// The managed private endpoint resource type. public partial class ManagedPrivateEndpointModelData : TrackedResourceData { - /// - /// 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 location. + /// The geo-location where the resource lives. public ManagedPrivateEndpointModelData(AzureLocation location) : base(location) { - GroupIds = new ChangeTrackingList(); } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. - /// Provisioning state of the resource. - /// The ARM resource ID of the resource for which the managed private endpoint is pointing to. - /// The region of the resource to which the managed private endpoint is pointing to. - /// The group Ids of the managed private endpoint. - /// User input request message of the managed private endpoint. - /// The state of managed private endpoint connection. - /// The URL of the data store behind the private link service. It would be the URL in the Grafana data source configuration page without the protocol and port. - /// The private IP of private endpoint after approval. This property is empty before connection is approved. - /// Keeps track of any properties unknown to the library. - internal ManagedPrivateEndpointModelData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, GrafanaProvisioningState? provisioningState, ResourceIdentifier privateLinkResourceId, string privateLinkResourceRegion, IList groupIds, string requestMessage, ManagedPrivateEndpointConnectionState connectionState, Uri privateLinkServiceUri, string privateLinkServicePrivateIP, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// Resource properties. + internal ManagedPrivateEndpointModelData(string id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, ManagedPrivateEndpointModelProperties properties) : base(id, name, resourceType, systemData, tags, location) { - ProvisioningState = provisioningState; - PrivateLinkResourceId = privateLinkResourceId; - PrivateLinkResourceRegion = privateLinkResourceRegion; - GroupIds = groupIds; - RequestMessage = requestMessage; - ConnectionState = connectionState; - PrivateLinkServiceUri = privateLinkServiceUri; - PrivateLinkServicePrivateIP = privateLinkServicePrivateIP; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; } - /// Initializes a new instance of for deserialization. - internal ManagedPrivateEndpointModelData() + /// Resource properties. + internal ManagedPrivateEndpointModelProperties Properties { get; set; } + + /// Provisioning state of the resource. + public GrafanaProvisioningState? ProvisioningState { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } } - /// Provisioning state of the resource. - public GrafanaProvisioningState? ProvisioningState { get; } /// The ARM resource ID of the resource for which the managed private endpoint is pointing to. - public ResourceIdentifier PrivateLinkResourceId { get; set; } + public ResourceIdentifier PrivateLinkResourceId + { + get + { + return Properties is null ? default : Properties.PrivateLinkResourceId; + } + set + { + if (Properties is null) + { + Properties = new ManagedPrivateEndpointModelProperties(); + } + Properties.PrivateLinkResourceId = value; + } + } + /// The region of the resource to which the managed private endpoint is pointing to. - public string PrivateLinkResourceRegion { get; set; } + public string PrivateLinkResourceRegion + { + get + { + return Properties is null ? default : Properties.PrivateLinkResourceRegion; + } + set + { + if (Properties is null) + { + Properties = new ManagedPrivateEndpointModelProperties(); + } + Properties.PrivateLinkResourceRegion = value; + } + } + /// The group Ids of the managed private endpoint. - public IList GroupIds { get; } + public IList GroupIds + { + get + { + if (Properties is null) + { + Properties = new ManagedPrivateEndpointModelProperties(); + } + return Properties.GroupIds; + } + } + /// User input request message of the managed private endpoint. - public string RequestMessage { get; set; } + public string RequestMessage + { + get + { + return Properties is null ? default : Properties.RequestMessage; + } + set + { + if (Properties is null) + { + Properties = new ManagedPrivateEndpointModelProperties(); + } + Properties.RequestMessage = value; + } + } + /// The state of managed private endpoint connection. - public ManagedPrivateEndpointConnectionState ConnectionState { get; } + public ManagedPrivateEndpointConnectionState ConnectionState + { + get + { + return Properties is null ? default : Properties.ConnectionState; + } + } + /// The URL of the data store behind the private link service. It would be the URL in the Grafana data source configuration page without the protocol and port. - public Uri PrivateLinkServiceUri { get; set; } + public Uri PrivateLinkServiceUri + { + get + { + return Properties is null ? default : Properties.PrivateLinkServiceUri; + } + set + { + if (Properties is null) + { + Properties = new ManagedPrivateEndpointModelProperties(); + } + Properties.PrivateLinkServiceUri = value; + } + } + /// The private IP of private endpoint after approval. This property is empty before connection is approved. - public string PrivateLinkServicePrivateIP { get; } + public string PrivateLinkServicePrivateIP + { + get + { + return Properties is null ? default : Properties.PrivateLinkServicePrivateIP; + } + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelResource.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelResource.Serialization.cs index 03e6a913238f..c29e1e4f5ed7 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelResource.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.Grafana { + /// public partial class ManagedPrivateEndpointModelResource : IJsonModel { - private static ManagedPrivateEndpointModelData s_dataDeserializationInstance; - private static ManagedPrivateEndpointModelData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new ManagedPrivateEndpointModelData(); + + /// 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); - ManagedPrivateEndpointModelData 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. + ManagedPrivateEndpointModelData 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, AzureResourceManagerGrafanaContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. ManagedPrivateEndpointModelData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerGrafanaContext.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/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelResource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelResource.cs index fa64d2eada75..45f6eb8ed5f4 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelResource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ManagedPrivateEndpointModelResource.cs @@ -7,47 +7,37 @@ using System; using System.Collections.Generic; -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.Grafana.Models; +using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.Grafana { /// - /// A Class representing a ManagedPrivateEndpointModel 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 GetManagedPrivateEndpointModelResource method. - /// Otherwise you can get one from its parent resource using the GetManagedPrivateEndpointModel method. + /// A class representing a ManagedPrivateEndpointModel 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 GetManagedPrivateEndpointModels method. /// public partial class ManagedPrivateEndpointModelResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The workspaceName. - /// The managedPrivateEndpointName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _managedPrivateEndpointModelClientDiagnostics; - private readonly ManagedPrivateEndpointModelsRestOperations _managedPrivateEndpointModelRestClient; + private readonly ClientDiagnostics _managedPrivateEndpointModelsClientDiagnostics; + private readonly ManagedPrivateEndpointModels _managedPrivateEndpointModelsRestClient; private readonly ManagedPrivateEndpointModelData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Dashboard/grafana/managedPrivateEndpoints"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of ManagedPrivateEndpointModelResource for mocking. protected ManagedPrivateEndpointModelResource() { } - /// 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 ManagedPrivateEndpointModelResource(ArmClient client, ManagedPrivateEndpointModelData data) : this(client, data.Id) @@ -56,71 +46,93 @@ internal ManagedPrivateEndpointModelResource(ArmClient client, ManagedPrivateEnd _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 ManagedPrivateEndpointModelResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _managedPrivateEndpointModelClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ResourceType.Namespace, Diagnostics); TryGetApiVersion(ResourceType, out string managedPrivateEndpointModelApiVersion); - _managedPrivateEndpointModelRestClient = new ManagedPrivateEndpointModelsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedPrivateEndpointModelApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + _managedPrivateEndpointModelsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Grafana", ResourceType.Namespace, Diagnostics); + _managedPrivateEndpointModelsRestClient = new ManagedPrivateEndpointModels(_managedPrivateEndpointModelsClientDiagnostics, Pipeline, Endpoint, managedPrivateEndpointModelApiVersion ?? "2025-09-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 ManagedPrivateEndpointModelData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The workspaceName. + /// The managedPrivateEndpointName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}"; + 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 a specific managed private endpoint of a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get + /// Operation Id. + /// ManagedPrivateEndpointModels_Get. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.Get"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.Get"); scope.Start(); try { - var response = await _managedPrivateEndpointModelRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -134,33 +146,41 @@ public virtual async Task> GetAsyn /// Get a specific managed private endpoint of a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get + /// Operation Id. + /// ManagedPrivateEndpointModels_Get. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.Get"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.Get"); scope.Start(); try { - var response = _managedPrivateEndpointModelRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -171,38 +191,55 @@ public virtual Response Get(CancellationTok } /// - /// Delete a managed private endpoint for a grafana resource. + /// Update a managed private endpoint for an existing grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Operation Id - /// ManagedPrivateEndpointModel_Delete + /// Operation Id. + /// ManagedPrivateEndpointModels_Update. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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. + /// Properties that can be updated to an existing managed private endpoint. /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, ManagedPrivateEndpointModelPatch patch, CancellationToken cancellationToken = default) { - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.Update"); scope.Start(); try { - var response = await _managedPrivateEndpointModelRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(_managedPrivateEndpointModelClientDiagnostics, Pipeline, _managedPrivateEndpointModelRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ManagedPrivateEndpointModelPatch.ToRequestContent(patch), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + GrafanaArmOperation operation = new GrafanaArmOperation( + new ManagedPrivateEndpointModelOperationSource(Client), + _managedPrivateEndpointModelsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -213,38 +250,55 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell } /// - /// Delete a managed private endpoint for a grafana resource. + /// Update a managed private endpoint for an existing grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Operation Id - /// ManagedPrivateEndpointModel_Delete + /// Operation Id. + /// ManagedPrivateEndpointModels_Update. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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. + /// Properties that can be updated to an existing managed private endpoint. /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, ManagedPrivateEndpointModelPatch patch, CancellationToken cancellationToken = default) { - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.Update"); scope.Start(); try { - var response = _managedPrivateEndpointModelRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new GrafanaArmOperation(_managedPrivateEndpointModelClientDiagnostics, Pipeline, _managedPrivateEndpointModelRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ManagedPrivateEndpointModelPatch.ToRequestContent(patch), context); + Response response = Pipeline.ProcessMessage(message, context); + GrafanaArmOperation operation = new GrafanaArmOperation( + new ManagedPrivateEndpointModelOperationSource(Client), + _managedPrivateEndpointModelsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); + { + operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -255,42 +309,45 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel } /// - /// Update a managed private endpoint for an existing grafana resource. + /// Delete a managed private endpoint for a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Operation Id - /// ManagedPrivateEndpointModel_Update + /// Operation Id. + /// ManagedPrivateEndpointModels_Delete. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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. - /// Properties that can be updated to an existing managed private endpoint. /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, ManagedPrivateEndpointModelPatch patch, CancellationToken cancellationToken = default) + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.Update"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.Delete"); scope.Start(); try { - var response = await _managedPrivateEndpointModelRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); - var operation = new GrafanaArmOperation(new ManagedPrivateEndpointModelOperationSource(Client), _managedPrivateEndpointModelClientDiagnostics, Pipeline, _managedPrivateEndpointModelRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + GrafanaArmOperation operation = new GrafanaArmOperation(_managedPrivateEndpointModelsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -301,42 +358,45 @@ public virtual async Task> Upd } /// - /// Update a managed private endpoint for an existing grafana resource. + /// Delete a managed private endpoint for a grafana resource. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}. /// /// - /// Operation Id - /// ManagedPrivateEndpointModel_Update + /// Operation Id. + /// ManagedPrivateEndpointModels_Delete. /// /// - /// Default Api Version - /// 2025-08-01 + /// Default Api Version. + /// 2025-09-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. - /// Properties that can be updated to an existing managed private endpoint. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, ManagedPrivateEndpointModelPatch patch, CancellationToken cancellationToken = default) + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.Update"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.Delete"); scope.Start(); try { - var response = _managedPrivateEndpointModelRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); - var operation = new GrafanaArmOperation(new ManagedPrivateEndpointModelOperationSource(Client), _managedPrivateEndpointModelClientDiagnostics, Pipeline, _managedPrivateEndpointModelRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + GrafanaArmOperation operation = new GrafanaArmOperation(_managedPrivateEndpointModelsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); + { + operation.WaitForCompletionResponse(cancellationToken); + } return operation; } catch (Exception e) @@ -346,27 +406,7 @@ public virtual ArmOperation Update(WaitUnti } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -376,28 +416,34 @@ public virtual async Task> AddTagA Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.AddTag"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.AddTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues[key] = value; - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _managedPrivateEndpointModelRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); + return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ManagedPrivateEndpointModelPatch(); - foreach (var tag in current.Tags) + ManagedPrivateEndpointModelData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ManagedPrivateEndpointModelPatch patch = new ManagedPrivateEndpointModelPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -408,27 +454,7 @@ public virtual async Task> AddTagA } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -438,28 +464,34 @@ public virtual Response AddTag(string key, Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.AddTag"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.AddTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues[key] = value; - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _managedPrivateEndpointModelRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); + return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ManagedPrivateEndpointModelPatch(); - foreach (var tag in current.Tags) + ManagedPrivateEndpointModelData current = Get(cancellationToken: cancellationToken).Value.Data; + ManagedPrivateEndpointModelPatch patch = new ManagedPrivateEndpointModelPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -470,53 +502,39 @@ public virtual Response AddTag(string key, } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// The cancellation token to use. /// is null. public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.SetTags"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.SetTags"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.ReplaceWith(tags); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _managedPrivateEndpointModelRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); + return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ManagedPrivateEndpointModelPatch(); + ManagedPrivateEndpointModelData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ManagedPrivateEndpointModelPatch patch = new ManagedPrivateEndpointModelPatch(); patch.Tags.ReplaceWith(tags); - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -527,53 +545,39 @@ public virtual async Task> SetTags } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// The cancellation token to use. /// is null. public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.SetTags"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.SetTags"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); - var originalTags = GetTagResource().Get(cancellationToken); + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.ReplaceWith(tags); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _managedPrivateEndpointModelRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); + return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ManagedPrivateEndpointModelPatch(); + ManagedPrivateEndpointModelData current = Get(cancellationToken: cancellationToken).Value.Data; + ManagedPrivateEndpointModelPatch patch = new ManagedPrivateEndpointModelPatch(); patch.Tags.ReplaceWith(tags); - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -584,27 +588,7 @@ public virtual Response SetTags(IDictionary } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -612,28 +596,34 @@ public virtual async Task> RemoveT { Argument.AssertNotNull(key, nameof(key)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.RemoveTag"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.RemoveTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.Remove(key); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _managedPrivateEndpointModelRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); + return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ManagedPrivateEndpointModelPatch(); - foreach (var tag in current.Tags) + ManagedPrivateEndpointModelData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ManagedPrivateEndpointModelPatch patch = new ManagedPrivateEndpointModelPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -644,27 +634,7 @@ public virtual async Task> RemoveT } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName} - /// - /// - /// Operation Id - /// ManagedPrivateEndpointModel_Get - /// - /// - /// Default Api Version - /// 2025-08-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -672,28 +642,34 @@ public virtual Response RemoveTag(string ke { Argument.AssertNotNull(key, nameof(key)); - using var scope = _managedPrivateEndpointModelClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.RemoveTag"); + using DiagnosticScope scope = _managedPrivateEndpointModelsClientDiagnostics.CreateScope("ManagedPrivateEndpointModelResource.RemoveTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.Remove(key); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _managedPrivateEndpointModelRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedPrivateEndpointModelsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedPrivateEndpointModelData.FromResponse(result), result); + return Response.FromValue(new ManagedPrivateEndpointModelResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ManagedPrivateEndpointModelPatch(); - foreach (var tag in current.Tags) + ManagedPrivateEndpointModelData current = Get(cancellationToken: cancellationToken).Value.Data; + ManagedPrivateEndpointModelPatch patch = new ManagedPrivateEndpointModelPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/AutoGeneratedDomainNameLabelScope.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/AutoGeneratedDomainNameLabelScope.cs index ea42a46d2684..85540c88215a 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/AutoGeneratedDomainNameLabelScope.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/AutoGeneratedDomainNameLabelScope.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { @@ -14,35 +15,51 @@ namespace Azure.ResourceManager.Grafana.Models public readonly partial struct AutoGeneratedDomainNameLabelScope : IEquatable { private readonly string _value; + private const string TenantReuseValue = "TenantReuse"; /// Initializes a new instance of . + /// The value. /// is null. public AutoGeneratedDomainNameLabelScope(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string TenantReuseValue = "TenantReuse"; + _value = value; + } - /// TenantReuse. + /// Gets the TenantReuse. public static AutoGeneratedDomainNameLabelScope TenantReuse { get; } = new AutoGeneratedDomainNameLabelScope(TenantReuseValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(AutoGeneratedDomainNameLabelScope left, AutoGeneratedDomainNameLabelScope 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 !=(AutoGeneratedDomainNameLabelScope left, AutoGeneratedDomainNameLabelScope right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator AutoGeneratedDomainNameLabelScope(string value) => new AutoGeneratedDomainNameLabelScope(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator AutoGeneratedDomainNameLabelScope?(string value) => value == null ? null : new AutoGeneratedDomainNameLabelScope(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is AutoGeneratedDomainNameLabelScope other && Equals(other); - /// + + /// public bool Equals(AutoGeneratedDomainNameLabelScope 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/AvailablePromotion.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/AvailablePromotion.cs index 54a1380d4e1e..0be0e4461b66 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/AvailablePromotion.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/AvailablePromotion.cs @@ -7,45 +7,63 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - /// The AvailablePromotion. + /// public readonly partial struct AvailablePromotion : IEquatable { private readonly string _value; + private const string NoneValue = "None"; + private const string FreeTrialValue = "FreeTrial"; /// Initializes a new instance of . + /// The value. /// is null. public AvailablePromotion(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string NoneValue = "None"; - private const string FreeTrialValue = "FreeTrial"; + _value = value; + } - /// None. + /// Gets the None. public static AvailablePromotion None { get; } = new AvailablePromotion(NoneValue); - /// FreeTrial. + + /// Gets the FreeTrial. public static AvailablePromotion FreeTrial { get; } = new AvailablePromotion(FreeTrialValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(AvailablePromotion left, AvailablePromotion 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 !=(AvailablePromotion left, AvailablePromotion right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator AvailablePromotion(string value) => new AvailablePromotion(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator AvailablePromotion?(string value) => value == null ? null : new AvailablePromotion(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is AvailablePromotion other && Equals(other); - /// + + /// public bool Equals(AvailablePromotion 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/AzureResourceManagerGrafanaContext.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/AzureResourceManagerGrafanaContext.cs index 4503edd982ef..35b2993eb4b3 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/AzureResourceManagerGrafanaContext.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/AzureResourceManagerGrafanaContext.cs @@ -6,16 +6,20 @@ #nullable disable using System.ClientModel.Primitives; +using Azure; using Azure.ResourceManager.Grafana.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources.Models; namespace Azure.ResourceManager.Grafana { /// /// 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(DashboardDefinitionData))] + [ModelReaderWriterBuildable(typeof(DashboardDefinitionListResponse))] + [ModelReaderWriterBuildable(typeof(DashboardDefinitionProperties))] + [ModelReaderWriterBuildable(typeof(DashboardDefinitionResource))] [ModelReaderWriterBuildable(typeof(EnterpriseConfigurations))] [ModelReaderWriterBuildable(typeof(EnterpriseDetails))] [ModelReaderWriterBuildable(typeof(GrafanaAvailablePlugin))] @@ -33,6 +37,7 @@ namespace Azure.ResourceManager.Grafana [ModelReaderWriterBuildable(typeof(GrafanaPrivateLinkResource))] [ModelReaderWriterBuildable(typeof(GrafanaPrivateLinkResourceData))] [ModelReaderWriterBuildable(typeof(GrafanaPrivateLinkResourceListResult))] + [ModelReaderWriterBuildable(typeof(GrafanaPrivateLinkResourceProperties))] [ModelReaderWriterBuildable(typeof(GrafanaPrivateLinkServiceConnectionState))] [ModelReaderWriterBuildable(typeof(GrafanaSecuritySettings))] [ModelReaderWriterBuildable(typeof(GrafanaSmtpSettings))] @@ -43,6 +48,7 @@ namespace Azure.ResourceManager.Grafana [ModelReaderWriterBuildable(typeof(ManagedDashboardData))] [ModelReaderWriterBuildable(typeof(ManagedDashboardListResponse))] [ModelReaderWriterBuildable(typeof(ManagedDashboardPatch))] + [ModelReaderWriterBuildable(typeof(ManagedDashboardProperties))] [ModelReaderWriterBuildable(typeof(ManagedDashboardResource))] [ModelReaderWriterBuildable(typeof(ManagedGrafanaData))] [ModelReaderWriterBuildable(typeof(ManagedGrafanaListResponse))] @@ -55,13 +61,15 @@ namespace Azure.ResourceManager.Grafana [ModelReaderWriterBuildable(typeof(ManagedPrivateEndpointModelData))] [ModelReaderWriterBuildable(typeof(ManagedPrivateEndpointModelListResponse))] [ModelReaderWriterBuildable(typeof(ManagedPrivateEndpointModelPatch))] + [ModelReaderWriterBuildable(typeof(ManagedPrivateEndpointModelProperties))] [ModelReaderWriterBuildable(typeof(ManagedPrivateEndpointModelResource))] [ModelReaderWriterBuildable(typeof(ManagedServiceIdentity))] [ModelReaderWriterBuildable(typeof(MarketplaceTrialQuota))] [ModelReaderWriterBuildable(typeof(MonitorWorkspaceIntegration))] + [ModelReaderWriterBuildable(typeof(PrivateEndpoint))] + [ModelReaderWriterBuildable(typeof(PrivateEndpointConnectionProperties))] [ModelReaderWriterBuildable(typeof(ResponseError))] [ModelReaderWriterBuildable(typeof(SaasSubscriptionDetails))] - [ModelReaderWriterBuildable(typeof(SubResource))] [ModelReaderWriterBuildable(typeof(SubscriptionTerm))] [ModelReaderWriterBuildable(typeof(SystemData))] [ModelReaderWriterBuildable(typeof(UnifiedAlertingScreenshots))] diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DashboardDefinitionListResponse.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DashboardDefinitionListResponse.Serialization.cs new file mode 100644 index 000000000000..f6ebf4252200 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DashboardDefinitionListResponse.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.Grafana; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// The list response for dashboard definitions. + internal partial class DashboardDefinitionListResponse : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal DashboardDefinitionListResponse() + { + } + + /// 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(DashboardDefinitionListResponse)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (DashboardDefinitionData item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + DashboardDefinitionListResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DashboardDefinitionListResponse 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(DashboardDefinitionListResponse)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDashboardDefinitionListResponse(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DashboardDefinitionListResponse DeserializeDashboardDefinitionListResponse(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DashboardDefinitionData.DeserializeDashboardDefinitionData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DashboardDefinitionListResponse(value, nextLink, 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, AzureResourceManagerGrafanaContext.Default); + default: + throw new FormatException($"The model {nameof(DashboardDefinitionListResponse)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + DashboardDefinitionListResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DashboardDefinitionListResponse 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 DeserializeDashboardDefinitionListResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DashboardDefinitionListResponse)} 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 DashboardDefinitionListResponse FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDashboardDefinitionListResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DashboardDefinitionListResponse.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DashboardDefinitionListResponse.cs new file mode 100644 index 000000000000..0ad381220a75 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DashboardDefinitionListResponse.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.ResourceManager.Grafana; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// The list response for dashboard definitions. + internal partial class DashboardDefinitionListResponse + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The DashboardDefinition items on this page. + internal DashboardDefinitionListResponse(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The DashboardDefinition items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal DashboardDefinitionListResponse(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The DashboardDefinition items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DashboardDefinitionProperties.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DashboardDefinitionProperties.Serialization.cs new file mode 100644 index 000000000000..45e8a81dbbd6 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DashboardDefinitionProperties.Serialization.cs @@ -0,0 +1,156 @@ +// 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.Grafana; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// Properties specific to the dashboard definition. + public partial class DashboardDefinitionProperties : 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(DashboardDefinitionProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(SerializedData)) + { + writer.WritePropertyName("serializedData"u8); + writer.WriteStringValue(SerializedData); + } + 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. + DashboardDefinitionProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DashboardDefinitionProperties 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(DashboardDefinitionProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDashboardDefinitionProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DashboardDefinitionProperties DeserializeDashboardDefinitionProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string serializedData = default; + GrafanaProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("serializedData"u8)) + { + serializedData = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new GrafanaProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DashboardDefinitionProperties(serializedData, 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, AzureResourceManagerGrafanaContext.Default); + default: + throw new FormatException($"The model {nameof(DashboardDefinitionProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + DashboardDefinitionProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DashboardDefinitionProperties 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 DeserializeDashboardDefinitionProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DashboardDefinitionProperties)} 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DashboardDefinitionProperties.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DashboardDefinitionProperties.cs new file mode 100644 index 000000000000..81c4f7a285ae --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DashboardDefinitionProperties.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// Properties specific to the dashboard definition. + public partial class DashboardDefinitionProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public DashboardDefinitionProperties() + { + } + + /// Initializes a new instance of . + /// The dashboard definition data in JSON format. + /// The provisioning state of the dashboard definition resource. + /// Keeps track of any properties unknown to the library. + internal DashboardDefinitionProperties(string serializedData, GrafanaProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + SerializedData = serializedData; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The dashboard definition data in JSON format. + public string SerializedData { get; set; } + + /// The provisioning state of the dashboard definition resource. + public GrafanaProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DeterministicOutboundIP.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DeterministicOutboundIP.cs index 21bff916101e..2f925ad33418 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DeterministicOutboundIP.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/DeterministicOutboundIP.cs @@ -7,45 +7,63 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - /// The DeterministicOutboundIP. + /// public readonly partial struct DeterministicOutboundIP : IEquatable { private readonly string _value; + private const string DisabledValue = "Disabled"; + private const string EnabledValue = "Enabled"; /// Initializes a new instance of . + /// The value. /// is null. public DeterministicOutboundIP(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string DisabledValue = "Disabled"; - private const string EnabledValue = "Enabled"; + _value = value; + } - /// Disabled. + /// Gets the Disabled. public static DeterministicOutboundIP Disabled { get; } = new DeterministicOutboundIP(DisabledValue); - /// Enabled. + + /// Gets the Enabled. public static DeterministicOutboundIP Enabled { get; } = new DeterministicOutboundIP(EnabledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DeterministicOutboundIP left, DeterministicOutboundIP 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 !=(DeterministicOutboundIP left, DeterministicOutboundIP right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DeterministicOutboundIP(string value) => new DeterministicOutboundIP(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DeterministicOutboundIP?(string value) => value == null ? null : new DeterministicOutboundIP(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DeterministicOutboundIP other && Equals(other); - /// + + /// public bool Equals(DeterministicOutboundIP 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseConfigurations.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseConfigurations.Serialization.cs index d50e35c1c1df..fad1a4e9ea40 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseConfigurations.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseConfigurations.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class EnterpriseConfigurations : IUtf8JsonSerializable, IJsonModel + /// Enterprise settings of a Grafana instance. + public partial class EnterpriseConfigurations : 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(EnterpriseConfigurations)} does not support writing '{format}' format."); } - if (Optional.IsDefined(MarketplacePlanId)) { writer.WritePropertyName("marketplacePlanId"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("marketplaceAutoRenew"u8); writer.WriteStringValue(MarketplaceAutoRenew.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); } @@ -61,59 +61,65 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - EnterpriseConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + EnterpriseConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EnterpriseConfigurations 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(EnterpriseConfigurations)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeEnterpriseConfigurations(document.RootElement, options); } - internal static EnterpriseConfigurations DeserializeEnterpriseConfigurations(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EnterpriseConfigurations DeserializeEnterpriseConfigurations(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string marketplacePlanId = default; MarketplaceAutoRenew? marketplaceAutoRenew = 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("marketplacePlanId"u8)) + if (prop.NameEquals("marketplacePlanId"u8)) { - marketplacePlanId = property.Value.GetString(); + marketplacePlanId = prop.Value.GetString(); continue; } - if (property.NameEquals("marketplaceAutoRenew"u8)) + if (prop.NameEquals("marketplaceAutoRenew"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - marketplaceAutoRenew = new MarketplaceAutoRenew(property.Value.GetString()); + marketplaceAutoRenew = new MarketplaceAutoRenew(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 EnterpriseConfigurations(marketplacePlanId, marketplaceAutoRenew, serializedAdditionalRawData); + return new EnterpriseConfigurations(marketplacePlanId, marketplaceAutoRenew, 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 } } - EnterpriseConfigurations 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. + EnterpriseConfigurations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EnterpriseConfigurations 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 DeserializeEnterpriseConfigurations(document.RootElement, options); } default: @@ -139,6 +150,7 @@ EnterpriseConfigurations IPersistableModel.Create(Bina } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseConfigurations.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseConfigurations.cs index e6b1bd90c834..34730a7d268d 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseConfigurations.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseConfigurations.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.Grafana.Models /// Enterprise settings of a Grafana instance. public partial class EnterpriseConfigurations { - /// - /// 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 EnterpriseConfigurations() @@ -53,16 +24,17 @@ public EnterpriseConfigurations() /// Initializes a new instance of . /// The Plan Id of the Azure Marketplace subscription for the Enterprise plugins. /// The AutoRenew setting of the Enterprise subscription. - /// Keeps track of any properties unknown to the library. - internal EnterpriseConfigurations(string marketplacePlanId, MarketplaceAutoRenew? marketplaceAutoRenew, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal EnterpriseConfigurations(string marketplacePlanId, MarketplaceAutoRenew? marketplaceAutoRenew, IDictionary additionalBinaryDataProperties) { MarketplacePlanId = marketplacePlanId; MarketplaceAutoRenew = marketplaceAutoRenew; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The Plan Id of the Azure Marketplace subscription for the Enterprise plugins. public string MarketplacePlanId { get; set; } + /// The AutoRenew setting of the Enterprise subscription. public MarketplaceAutoRenew? MarketplaceAutoRenew { get; set; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseDetails.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseDetails.Serialization.cs index bf0d73011407..5531b9f21427 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseDetails.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseDetails.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.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class EnterpriseDetails : IUtf8JsonSerializable, IJsonModel + /// Enterprise details of a Grafana instance. + public partial class EnterpriseDetails : 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, 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(EnterpriseDetails)} does not support writing '{format}' format."); } - if (Optional.IsDefined(SaasSubscriptionDetails)) { writer.WritePropertyName("saasSubscriptionDetails"u8); @@ -44,15 +45,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("marketplaceTrialQuota"u8); writer.WriteObjectValue(MarketplaceTrialQuota, 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); } @@ -61,63 +62,69 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - EnterpriseDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + EnterpriseDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EnterpriseDetails 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(EnterpriseDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeEnterpriseDetails(document.RootElement, options); } - internal static EnterpriseDetails DeserializeEnterpriseDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EnterpriseDetails DeserializeEnterpriseDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } SaasSubscriptionDetails saasSubscriptionDetails = default; MarketplaceTrialQuota marketplaceTrialQuota = 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("saasSubscriptionDetails"u8)) + if (prop.NameEquals("saasSubscriptionDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - saasSubscriptionDetails = SaasSubscriptionDetails.DeserializeSaasSubscriptionDetails(property.Value, options); + saasSubscriptionDetails = SaasSubscriptionDetails.DeserializeSaasSubscriptionDetails(prop.Value, options); continue; } - if (property.NameEquals("marketplaceTrialQuota"u8)) + if (prop.NameEquals("marketplaceTrialQuota"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - marketplaceTrialQuota = MarketplaceTrialQuota.DeserializeMarketplaceTrialQuota(property.Value, options); + marketplaceTrialQuota = MarketplaceTrialQuota.DeserializeMarketplaceTrialQuota(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 EnterpriseDetails(saasSubscriptionDetails, marketplaceTrialQuota, serializedAdditionalRawData); + return new EnterpriseDetails(saasSubscriptionDetails, marketplaceTrialQuota, 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": @@ -127,15 +134,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - EnterpriseDetails 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. + EnterpriseDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EnterpriseDetails 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 DeserializeEnterpriseDetails(document.RootElement, options); } default: @@ -143,6 +155,14 @@ EnterpriseDetails IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static EnterpriseDetails FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnterpriseDetails(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseDetails.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseDetails.cs index 5c0131773e7c..ea9cbf7e03f8 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseDetails.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/EnterpriseDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.Grafana.Models /// Enterprise details of a Grafana instance. public partial class EnterpriseDetails { - /// - /// 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 EnterpriseDetails() @@ -53,16 +24,17 @@ internal EnterpriseDetails() /// Initializes a new instance of . /// SaaS subscription details of a Grafana instance. /// The allocation details of the per subscription free trial slot of the subscription. - /// Keeps track of any properties unknown to the library. - internal EnterpriseDetails(SaasSubscriptionDetails saasSubscriptionDetails, MarketplaceTrialQuota marketplaceTrialQuota, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal EnterpriseDetails(SaasSubscriptionDetails saasSubscriptionDetails, MarketplaceTrialQuota marketplaceTrialQuota, IDictionary additionalBinaryDataProperties) { SaasSubscriptionDetails = saasSubscriptionDetails; MarketplaceTrialQuota = marketplaceTrialQuota; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// SaaS subscription details of a Grafana instance. public SaasSubscriptionDetails SaasSubscriptionDetails { get; } + /// The allocation details of the per subscription free trial slot of the subscription. public MarketplaceTrialQuota MarketplaceTrialQuota { get; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaApiKey.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaApiKey.cs index 14607f055a64..da329c6f7dce 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaApiKey.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaApiKey.cs @@ -7,45 +7,63 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - /// The GrafanaApiKey. + /// public readonly partial struct GrafanaApiKey : IEquatable { private readonly string _value; + private const string DisabledValue = "Disabled"; + private const string EnabledValue = "Enabled"; /// Initializes a new instance of . + /// The value. /// is null. public GrafanaApiKey(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string DisabledValue = "Disabled"; - private const string EnabledValue = "Enabled"; + _value = value; + } - /// Disabled. + /// Gets the Disabled. public static GrafanaApiKey Disabled { get; } = new GrafanaApiKey(DisabledValue); - /// Enabled. + + /// Gets the Enabled. public static GrafanaApiKey Enabled { get; } = new GrafanaApiKey(EnabledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(GrafanaApiKey left, GrafanaApiKey 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 !=(GrafanaApiKey left, GrafanaApiKey right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator GrafanaApiKey(string value) => new GrafanaApiKey(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator GrafanaApiKey?(string value) => value == null ? null : new GrafanaApiKey(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is GrafanaApiKey other && Equals(other); - /// + + /// public bool Equals(GrafanaApiKey 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePlugin.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePlugin.Serialization.cs index 023674d59271..b4ddb71d6d01 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePlugin.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePlugin.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class GrafanaAvailablePlugin : IUtf8JsonSerializable, IJsonModel + /// Available plugins of grafana. + public partial class GrafanaAvailablePlugin : 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(GrafanaAvailablePlugin)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(PluginId)) { writer.WritePropertyName("pluginId"u8); @@ -54,15 +54,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("author"u8); writer.WriteStringValue(Author); } - 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,67 +71,73 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - GrafanaAvailablePlugin IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaAvailablePlugin IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaAvailablePlugin 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(GrafanaAvailablePlugin)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaAvailablePlugin(document.RootElement, options); } - internal static GrafanaAvailablePlugin DeserializeGrafanaAvailablePlugin(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaAvailablePlugin DeserializeGrafanaAvailablePlugin(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string pluginId = default; string name = default; - string type = default; + string @type = default; string author = 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("pluginId"u8)) + if (prop.NameEquals("pluginId"u8)) { - pluginId = property.Value.GetString(); + pluginId = 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 = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("author"u8)) + if (prop.NameEquals("author"u8)) { - author = property.Value.GetString(); + author = 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 GrafanaAvailablePlugin(pluginId, name, type, author, serializedAdditionalRawData); + return new GrafanaAvailablePlugin(pluginId, name, @type, author, 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": @@ -141,15 +147,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - GrafanaAvailablePlugin 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. + GrafanaAvailablePlugin IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaAvailablePlugin 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 DeserializeGrafanaAvailablePlugin(document.RootElement, options); } default: @@ -157,6 +168,7 @@ GrafanaAvailablePlugin IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePlugin.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePlugin.cs index e78f2f9e7f69..313f4796249a 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePlugin.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePlugin.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.Grafana.Models /// Available plugins of grafana. public partial class GrafanaAvailablePlugin { - /// - /// 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 GrafanaAvailablePlugin() @@ -55,22 +26,25 @@ internal GrafanaAvailablePlugin() /// Grafana plugin display name. /// Grafana plugin type. /// Grafana plugin author/publisher name. - /// Keeps track of any properties unknown to the library. - internal GrafanaAvailablePlugin(string pluginId, string name, string type, string author, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaAvailablePlugin(string pluginId, string name, string @type, string author, IDictionary additionalBinaryDataProperties) { PluginId = pluginId; Name = name; - Type = type; + Type = @type; Author = author; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Grafana plugin id. public string PluginId { get; } + /// Grafana plugin display name. public string Name { get; } + /// Grafana plugin type. public string Type { get; } + /// Grafana plugin author/publisher name. public string Author { get; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePluginListResponse.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePluginListResponse.Serialization.cs index dc6046889627..fb1c07db9b6e 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePluginListResponse.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePluginListResponse.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.Grafana; namespace Azure.ResourceManager.Grafana.Models { - internal partial class GrafanaAvailablePluginListResponse : IUtf8JsonSerializable, IJsonModel + /// The GrafanaAvailablePluginListResponse. + public partial class GrafanaAvailablePluginListResponse : 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 +30,16 @@ void IJsonModel.Write(Utf8JsonWriter 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(GrafanaAvailablePluginListResponse)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Value)) { writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (GrafanaAvailablePlugin item in Value) { writer.WriteObjectValue(item, options); } @@ -49,15 +50,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink); } - 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 +67,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - GrafanaAvailablePluginListResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaAvailablePluginListResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaAvailablePluginListResponse 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(GrafanaAvailablePluginListResponse)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaAvailablePluginListResponse(document.RootElement, options); } - internal static GrafanaAvailablePluginListResponse DeserializeGrafanaAvailablePluginListResponse(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaAvailablePluginListResponse DeserializeGrafanaAvailablePluginListResponse(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; string 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)) { - 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(GrafanaAvailablePlugin.DeserializeGrafanaAvailablePlugin(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - nextLink = property.Value.GetString(); + nextLink = 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 GrafanaAvailablePluginListResponse(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); + return new GrafanaAvailablePluginListResponse(value ?? new ChangeTrackingList(), 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": @@ -133,15 +140,20 @@ BinaryData IPersistableModel.Write(ModelRead } } - GrafanaAvailablePluginListResponse 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. + GrafanaAvailablePluginListResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaAvailablePluginListResponse 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 DeserializeGrafanaAvailablePluginListResponse(document.RootElement, options); } default: @@ -149,6 +161,14 @@ GrafanaAvailablePluginListResponse IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static GrafanaAvailablePluginListResponse FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGrafanaAvailablePluginListResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePluginListResponse.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePluginListResponse.cs index e3c24b9a9cfb..6dda503ac81f 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePluginListResponse.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaAvailablePluginListResponse.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// The GrafanaAvailablePluginListResponse. - internal partial class GrafanaAvailablePluginListResponse + public partial class GrafanaAvailablePluginListResponse { - /// - /// 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 GrafanaAvailablePluginListResponse() @@ -54,17 +26,18 @@ internal GrafanaAvailablePluginListResponse() /// Initializes a new instance of . /// /// - /// Keeps track of any properties unknown to the library. - internal GrafanaAvailablePluginListResponse(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaAvailablePluginListResponse(IList value, string nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } - /// Gets the value. - public IReadOnlyList Value { get; } - /// Gets the next link. + /// Gets the Value. + public IList Value { get; } + + /// Gets the NextLink. public string NextLink { get; } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaConfigurations.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaConfigurations.Serialization.cs index cf9dd5c470e1..49905744ed71 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaConfigurations.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaConfigurations.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class GrafanaConfigurations : IUtf8JsonSerializable, IJsonModel + /// Server configurations of a Grafana instance. + public partial class GrafanaConfigurations : 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, 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(GrafanaConfigurations)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Smtp)) { writer.WritePropertyName("smtp"u8); @@ -59,15 +59,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("unifiedAlertingScreenshots"u8); writer.WriteObjectValue(UnifiedAlertingScreenshots, 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 } } - GrafanaConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaConfigurations 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(GrafanaConfigurations)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaConfigurations(document.RootElement, options); } - internal static GrafanaConfigurations DeserializeGrafanaConfigurations(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaConfigurations DeserializeGrafanaConfigurations(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -101,74 +106,75 @@ internal static GrafanaConfigurations DeserializeGrafanaConfigurations(JsonEleme GrafanaUserSettings users = default; GrafanaSecuritySettings security = default; UnifiedAlertingScreenshots unifiedAlertingScreenshots = 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("smtp"u8)) + if (prop.NameEquals("smtp"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - smtp = GrafanaSmtpSettings.DeserializeGrafanaSmtpSettings(property.Value, options); + smtp = GrafanaSmtpSettings.DeserializeGrafanaSmtpSettings(prop.Value, options); continue; } - if (property.NameEquals("snapshots"u8)) + if (prop.NameEquals("snapshots"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - snapshots = GrafanaSnapshotsSettings.DeserializeGrafanaSnapshotsSettings(property.Value, options); + snapshots = GrafanaSnapshotsSettings.DeserializeGrafanaSnapshotsSettings(prop.Value, options); continue; } - if (property.NameEquals("users"u8)) + if (prop.NameEquals("users"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - users = GrafanaUserSettings.DeserializeGrafanaUserSettings(property.Value, options); + users = GrafanaUserSettings.DeserializeGrafanaUserSettings(prop.Value, options); continue; } - if (property.NameEquals("security"u8)) + if (prop.NameEquals("security"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - security = GrafanaSecuritySettings.DeserializeGrafanaSecuritySettings(property.Value, options); + security = GrafanaSecuritySettings.DeserializeGrafanaSecuritySettings(prop.Value, options); continue; } - if (property.NameEquals("unifiedAlertingScreenshots"u8)) + if (prop.NameEquals("unifiedAlertingScreenshots"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - unifiedAlertingScreenshots = UnifiedAlertingScreenshots.DeserializeUnifiedAlertingScreenshots(property.Value, options); + unifiedAlertingScreenshots = UnifiedAlertingScreenshots.DeserializeUnifiedAlertingScreenshots(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 GrafanaConfigurations( smtp, snapshots, users, security, unifiedAlertingScreenshots, - 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": @@ -178,15 +184,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - GrafanaConfigurations 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. + GrafanaConfigurations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaConfigurations 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 DeserializeGrafanaConfigurations(document.RootElement, options); } default: @@ -194,6 +205,7 @@ GrafanaConfigurations IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaConfigurations.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaConfigurations.cs index 88091195ad48..04c8fd0bcc4c 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaConfigurations.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaConfigurations.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.Grafana.Models /// Server configurations of a Grafana instance. public partial class GrafanaConfigurations { - /// - /// 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 GrafanaConfigurations() @@ -59,15 +30,15 @@ public GrafanaConfigurations() /// Grafana users settings. /// Grafana security settings. /// Grafana Unified Alerting Screenshots settings. - /// Keeps track of any properties unknown to the library. - internal GrafanaConfigurations(GrafanaSmtpSettings smtp, GrafanaSnapshotsSettings snapshots, GrafanaUserSettings users, GrafanaSecuritySettings security, UnifiedAlertingScreenshots unifiedAlertingScreenshots, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaConfigurations(GrafanaSmtpSettings smtp, GrafanaSnapshotsSettings snapshots, GrafanaUserSettings users, GrafanaSecuritySettings security, UnifiedAlertingScreenshots unifiedAlertingScreenshots, IDictionary additionalBinaryDataProperties) { Smtp = smtp; Snapshots = snapshots; Users = users; Security = security; UnifiedAlertingScreenshots = unifiedAlertingScreenshots; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// @@ -75,46 +46,66 @@ internal GrafanaConfigurations(GrafanaSmtpSettings smtp, GrafanaSnapshotsSetting /// https://grafana.com/docs/grafana/v9.0/setup-grafana/configure-grafana/#smtp /// public GrafanaSmtpSettings Smtp { get; set; } + /// Grafana Snapshots settings. internal GrafanaSnapshotsSettings Snapshots { get; set; } + + /// Grafana users settings. + public GrafanaUserSettings Users { get; set; } + + /// Grafana security settings. + internal GrafanaSecuritySettings Security { get; set; } + + /// Grafana Unified Alerting Screenshots settings. + internal UnifiedAlertingScreenshots UnifiedAlertingScreenshots { get; set; } + /// Set to false to disable external snapshot publish endpoint. public bool? IsExternalEnabled { - get => Snapshots is null ? default : Snapshots.IsExternalEnabled; + get + { + return Snapshots is null ? default : Snapshots.IsExternalEnabled; + } set { if (Snapshots is null) + { Snapshots = new GrafanaSnapshotsSettings(); + } Snapshots.IsExternalEnabled = value; } } - /// Grafana users settings. - public GrafanaUserSettings Users { get; set; } - /// Grafana security settings. - internal GrafanaSecuritySettings Security { get; set; } /// Set to true to execute the CSRF check even if the login cookie is not in a request (default false). public bool? IsCsrfAlwaysCheckEnabled { - get => Security is null ? default : Security.IsCsrfAlwaysCheckEnabled; + get + { + return Security is null ? default : Security.IsCsrfAlwaysCheckEnabled; + } set { if (Security is null) + { Security = new GrafanaSecuritySettings(); + } Security.IsCsrfAlwaysCheckEnabled = value; } } - /// Grafana Unified Alerting Screenshots settings. - internal UnifiedAlertingScreenshots UnifiedAlertingScreenshots { get; set; } /// Set to false to disable capture screenshot in Unified Alert due to performance issue. public bool? IsCaptureEnabled { - get => UnifiedAlertingScreenshots is null ? default : UnifiedAlertingScreenshots.IsCaptureEnabled; + get + { + return UnifiedAlertingScreenshots is null ? default : UnifiedAlertingScreenshots.IsCaptureEnabled; + } set { if (UnifiedAlertingScreenshots is null) + { UnifiedAlertingScreenshots = new UnifiedAlertingScreenshots(); + } UnifiedAlertingScreenshots.IsCaptureEnabled = value; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaCreatorCanAdmin.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaCreatorCanAdmin.cs index 30b62accd83b..b5cd470b14b5 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaCreatorCanAdmin.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaCreatorCanAdmin.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { @@ -14,38 +15,57 @@ namespace Azure.ResourceManager.Grafana.Models public readonly partial struct GrafanaCreatorCanAdmin : IEquatable { private readonly string _value; + /// Creator admin access is disabled. + private const string DisabledValue = "Disabled"; + /// Creator admin access is enabled. + private const string EnabledValue = "Enabled"; /// Initializes a new instance of . + /// The value. /// is null. public GrafanaCreatorCanAdmin(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string DisabledValue = "Disabled"; - private const string EnabledValue = "Enabled"; + _value = value; + } /// Creator admin access is disabled. public static GrafanaCreatorCanAdmin Disabled { get; } = new GrafanaCreatorCanAdmin(DisabledValue); + /// Creator admin access is enabled. public static GrafanaCreatorCanAdmin Enabled { get; } = new GrafanaCreatorCanAdmin(EnabledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(GrafanaCreatorCanAdmin left, GrafanaCreatorCanAdmin 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 !=(GrafanaCreatorCanAdmin left, GrafanaCreatorCanAdmin right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator GrafanaCreatorCanAdmin(string value) => new GrafanaCreatorCanAdmin(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator GrafanaCreatorCanAdmin?(string value) => value == null ? null : new GrafanaCreatorCanAdmin(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is GrafanaCreatorCanAdmin other && Equals(other); - /// + + /// public bool Equals(GrafanaCreatorCanAdmin 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricPatch.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricPatch.Serialization.cs index e0b0f4a76379..df8f3bca3757 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricPatch.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricPatch.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class GrafanaIntegrationFabricPatch : IUtf8JsonSerializable, IJsonModel + /// The parameters for a PATCH request to a Integration Fabric resource. + public partial class GrafanaIntegrationFabricPatch : 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(GrafanaIntegrationFabricPatch)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -41,6 +42,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Tags) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); @@ -50,15 +56,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties, 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); } @@ -67,68 +73,81 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - GrafanaIntegrationFabricPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaIntegrationFabricPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaIntegrationFabricPatch 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(GrafanaIntegrationFabricPatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaIntegrationFabricPatch(document.RootElement, options); } - internal static GrafanaIntegrationFabricPatch DeserializeGrafanaIntegrationFabricPatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaIntegrationFabricPatch DeserializeGrafanaIntegrationFabricPatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IDictionary tags = default; IntegrationFabricPropertiesUpdateParameters properties = 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("tags"u8)) + if (prop.NameEquals("tags"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()); + } } tags = dictionary; continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = IntegrationFabricPropertiesUpdateParameters.DeserializeIntegrationFabricPropertiesUpdateParameters(property.Value, options); + properties = IntegrationFabricPropertiesUpdateParameters.DeserializeIntegrationFabricPropertiesUpdateParameters(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 GrafanaIntegrationFabricPatch(tags ?? new ChangeTrackingDictionary(), properties, serializedAdditionalRawData); + return new GrafanaIntegrationFabricPatch(tags ?? new ChangeTrackingDictionary(), 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": @@ -138,15 +157,20 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - GrafanaIntegrationFabricPatch 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. + GrafanaIntegrationFabricPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaIntegrationFabricPatch 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 DeserializeGrafanaIntegrationFabricPatch(document.RootElement, options); } default: @@ -154,6 +178,19 @@ GrafanaIntegrationFabricPatch IPersistableModel.C } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(GrafanaIntegrationFabricPatch grafanaIntegrationFabricPatch) + { + if (grafanaIntegrationFabricPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(grafanaIntegrationFabricPatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricPatch.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricPatch.cs index f8feceed6ddc..94dad01ad5fe 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricPatch.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricPatch.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// The parameters for a PATCH request to a Integration Fabric resource. public partial class GrafanaIntegrationFabricPatch { - /// - /// 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 GrafanaIntegrationFabricPatch() @@ -54,25 +26,29 @@ public GrafanaIntegrationFabricPatch() /// Initializes a new instance of . /// The new tags of the Integration Fabric resource. /// The new properties of this Integration Fabric resource. - /// Keeps track of any properties unknown to the library. - internal GrafanaIntegrationFabricPatch(IDictionary tags, IntegrationFabricPropertiesUpdateParameters properties, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaIntegrationFabricPatch(IDictionary tags, IntegrationFabricPropertiesUpdateParameters properties, IDictionary additionalBinaryDataProperties) { Tags = tags; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The new tags of the Integration Fabric resource. public IDictionary Tags { get; } + /// The new properties of this Integration Fabric resource. internal IntegrationFabricPropertiesUpdateParameters Properties { get; set; } + /// The new integration scenarios covered by this integration fabric. public IList IntegrationFabricPropertiesUpdateParametersScenarios { get { if (Properties is null) + { Properties = new IntegrationFabricPropertiesUpdateParameters(); + } return Properties.Scenarios; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricProperties.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricProperties.Serialization.cs index 19d97eabe233..e0c1b11fd35c 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricProperties.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricProperties.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class GrafanaIntegrationFabricProperties : IUtf8JsonSerializable, IJsonModel + /// The GrafanaIntegrationFabricProperties. + public partial class GrafanaIntegrationFabricProperties : 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, /// 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(GrafanaIntegrationFabricProperties)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) { writer.WritePropertyName("provisioningState"u8); @@ -53,21 +54,26 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("scenarios"u8); writer.WriteStartArray(); - foreach (var item in Scenarios) + foreach (string item in Scenarios) { + 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 +82,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - GrafanaIntegrationFabricProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaIntegrationFabricProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaIntegrationFabricProperties 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(GrafanaIntegrationFabricProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaIntegrationFabricProperties(document.RootElement, options); } - internal static GrafanaIntegrationFabricProperties DeserializeGrafanaIntegrationFabricProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaIntegrationFabricProperties DeserializeGrafanaIntegrationFabricProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -100,64 +111,72 @@ internal static GrafanaIntegrationFabricProperties DeserializeGrafanaIntegration ResourceIdentifier targetResourceId = default; ResourceIdentifier dataSourceResourceId = default; IList scenarios = 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("provisioningState"u8)) + if (prop.NameEquals("provisioningState"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - provisioningState = new GrafanaProvisioningState(property.Value.GetString()); + provisioningState = new GrafanaProvisioningState(prop.Value.GetString()); continue; } - if (property.NameEquals("targetResourceId"u8)) + if (prop.NameEquals("targetResourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - targetResourceId = new ResourceIdentifier(property.Value.GetString()); + targetResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("dataSourceResourceId"u8)) + if (prop.NameEquals("dataSourceResourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dataSourceResourceId = new ResourceIdentifier(property.Value.GetString()); + dataSourceResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("scenarios"u8)) + if (prop.NameEquals("scenarios"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()); + } } scenarios = 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 GrafanaIntegrationFabricProperties(provisioningState, targetResourceId, dataSourceResourceId, scenarios ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new GrafanaIntegrationFabricProperties(provisioningState, targetResourceId, dataSourceResourceId, scenarios ?? 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": @@ -167,15 +186,20 @@ BinaryData IPersistableModel.Write(ModelRead } } - GrafanaIntegrationFabricProperties 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. + GrafanaIntegrationFabricProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaIntegrationFabricProperties 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 DeserializeGrafanaIntegrationFabricProperties(document.RootElement, options); } default: @@ -183,6 +207,7 @@ GrafanaIntegrationFabricProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricProperties.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricProperties.cs index e0840841b4ae..61590ac5c9bf 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricProperties.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrationFabricProperties.cs @@ -8,43 +8,15 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// The GrafanaIntegrationFabricProperties. public partial class GrafanaIntegrationFabricProperties { - /// - /// 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 GrafanaIntegrationFabricProperties() @@ -57,22 +29,25 @@ public GrafanaIntegrationFabricProperties() /// The resource Id of the Azure resource being integrated with Azure Managed Grafana. E.g., an Azure Kubernetes Service cluster. /// The resource Id of the Azure resource which is used to configure Grafana data source. E.g., an Azure Monitor Workspace, an Azure Data Explorer cluster, etc. /// A list of integration scenarios covered by this integration fabric. - /// Keeps track of any properties unknown to the library. - internal GrafanaIntegrationFabricProperties(GrafanaProvisioningState? provisioningState, ResourceIdentifier targetResourceId, ResourceIdentifier dataSourceResourceId, IList scenarios, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaIntegrationFabricProperties(GrafanaProvisioningState? provisioningState, ResourceIdentifier targetResourceId, ResourceIdentifier dataSourceResourceId, IList scenarios, IDictionary additionalBinaryDataProperties) { ProvisioningState = provisioningState; TargetResourceId = targetResourceId; DataSourceResourceId = dataSourceResourceId; Scenarios = scenarios; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Provisioning state of the resource. public GrafanaProvisioningState? ProvisioningState { get; } + /// The resource Id of the Azure resource being integrated with Azure Managed Grafana. E.g., an Azure Kubernetes Service cluster. public ResourceIdentifier TargetResourceId { get; set; } + /// The resource Id of the Azure resource which is used to configure Grafana data source. E.g., an Azure Monitor Workspace, an Azure Data Explorer cluster, etc. public ResourceIdentifier DataSourceResourceId { get; set; } + /// A list of integration scenarios covered by this integration fabric. public IList Scenarios { get; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrations.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrations.Serialization.cs index 87bbae0fe50c..b0b5ee0ef149 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrations.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrations.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - internal partial class GrafanaIntegrations : IUtf8JsonSerializable, IJsonModel + /// GrafanaIntegrations is a bundled observability experience (e.g. pre-configured data source, tailored Grafana dashboards, alerting defaults) for common monitoring scenarios. + internal partial class GrafanaIntegrations : 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, 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(GrafanaIntegrations)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(MonitorWorkspaceIntegrations)) { writer.WritePropertyName("azureMonitorWorkspaceIntegrations"u8); writer.WriteStartArray(); - foreach (var item in MonitorWorkspaceIntegrations) + foreach (MonitorWorkspaceIntegration item in MonitorWorkspaceIntegrations) { 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,58 +61,64 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - GrafanaIntegrations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaIntegrations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaIntegrations 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(GrafanaIntegrations)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaIntegrations(document.RootElement, options); } - internal static GrafanaIntegrations DeserializeGrafanaIntegrations(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaIntegrations DeserializeGrafanaIntegrations(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IList azureMonitorWorkspaceIntegrations = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList monitorWorkspaceIntegrations = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("azureMonitorWorkspaceIntegrations"u8)) + if (prop.NameEquals("azureMonitorWorkspaceIntegrations"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(MonitorWorkspaceIntegration.DeserializeMonitorWorkspaceIntegration(item, options)); } - azureMonitorWorkspaceIntegrations = array; + monitorWorkspaceIntegrations = 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 GrafanaIntegrations(azureMonitorWorkspaceIntegrations ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new GrafanaIntegrations(monitorWorkspaceIntegrations ?? 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 } } - GrafanaIntegrations 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. + GrafanaIntegrations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaIntegrations 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 DeserializeGrafanaIntegrations(document.RootElement, options); } default: @@ -138,6 +149,7 @@ GrafanaIntegrations IPersistableModel.Create(BinaryData dat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrations.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrations.cs index 5466d442aa7b..bf87a200c174 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrations.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaIntegrations.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// GrafanaIntegrations is a bundled observability experience (e.g. pre-configured data source, tailored Grafana dashboards, alerting defaults) for common monitoring scenarios. internal partial class GrafanaIntegrations { - /// - /// 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 GrafanaIntegrations() @@ -53,14 +25,14 @@ public GrafanaIntegrations() /// Initializes a new instance of . /// - /// Keeps track of any properties unknown to the library. - internal GrafanaIntegrations(IList monitorWorkspaceIntegrations, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaIntegrations(IList monitorWorkspaceIntegrations, IDictionary additionalBinaryDataProperties) { MonitorWorkspaceIntegrations = monitorWorkspaceIntegrations; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } - /// Gets the monitor workspace integrations. + /// Gets the MonitorWorkspaceIntegrations. public IList MonitorWorkspaceIntegrations { get; } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPlugin.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPlugin.Serialization.cs index 9ef70516cbab..5c3e2804d9c3 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPlugin.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPlugin.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class GrafanaPlugin : IUtf8JsonSerializable, IJsonModel + /// Plugin of Grafana. + public partial class GrafanaPlugin : 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 +29,25 @@ 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(GrafanaPlugin)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(PluginId)) { writer.WritePropertyName("pluginId"u8); writer.WriteStringValue(PluginId); } - 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 +56,55 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - GrafanaPlugin IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaPlugin IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaPlugin 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(GrafanaPlugin)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaPlugin(document.RootElement, options); } - internal static GrafanaPlugin DeserializeGrafanaPlugin(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaPlugin DeserializeGrafanaPlugin(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string pluginId = 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("pluginId"u8)) + if (prop.NameEquals("pluginId"u8)) { - pluginId = property.Value.GetString(); + pluginId = 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 GrafanaPlugin(pluginId, serializedAdditionalRawData); + return new GrafanaPlugin(pluginId, 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 +114,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions optio } } - GrafanaPlugin 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. + GrafanaPlugin IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaPlugin 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 DeserializeGrafanaPlugin(document.RootElement, options); } default: @@ -124,6 +135,7 @@ GrafanaPlugin IPersistableModel.Create(BinaryData data, ModelRead } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPlugin.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPlugin.cs index c7e76827361a..76913aa6bf1e 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPlugin.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPlugin.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.Grafana.Models /// Plugin of Grafana. public partial class GrafanaPlugin { - /// - /// 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 GrafanaPlugin() @@ -52,11 +23,11 @@ public GrafanaPlugin() /// Initializes a new instance of . /// Grafana plugin id. - /// Keeps track of any properties unknown to the library. - internal GrafanaPlugin(string pluginId, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaPlugin(string pluginId, IDictionary additionalBinaryDataProperties) { PluginId = pluginId; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Grafana plugin id. diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointConnectionListResult.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointConnectionListResult.Serialization.cs index 1172d6259940..1fa17c986cde 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointConnectionListResult.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointConnectionListResult.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.Grafana; namespace Azure.ResourceManager.Grafana.Models { - internal partial class GrafanaPrivateEndpointConnectionListResult : IUtf8JsonSerializable, IJsonModel + /// The response of a PrivateEndpointConnection list operation. + internal partial class GrafanaPrivateEndpointConnectionListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal GrafanaPrivateEndpointConnectionListResult() + { + } + /// 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 /// 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(GrafanaPrivateEndpointConnectionListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (GrafanaPrivateEndpointConnectionData 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 } } - GrafanaPrivateEndpointConnectionListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaPrivateEndpointConnectionListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaPrivateEndpointConnectionListResult 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(GrafanaPrivateEndpointConnectionListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaPrivateEndpointConnectionListResult(document.RootElement, options); } - internal static GrafanaPrivateEndpointConnectionListResult DeserializeGrafanaPrivateEndpointConnectionListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaPrivateEndpointConnectionListResult DeserializeGrafanaPrivateEndpointConnectionListResult(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(GrafanaPrivateEndpointConnectionData.DeserializeGrafanaPrivateEndpointConnectionData(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 GrafanaPrivateEndpointConnectionListResult(value, nextLink, serializedAdditionalRawData); + return new GrafanaPrivateEndpointConnectionListResult(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(M } } - GrafanaPrivateEndpointConnectionListResult 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. + GrafanaPrivateEndpointConnectionListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaPrivateEndpointConnectionListResult 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 DeserializeGrafanaPrivateEndpointConnectionListResult(document.RootElement, options); } default: @@ -146,6 +163,14 @@ GrafanaPrivateEndpointConnectionListResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static GrafanaPrivateEndpointConnectionListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGrafanaPrivateEndpointConnectionListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointConnectionListResult.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointConnectionListResult.cs index 05d99c57e0d9..16a2c7dc4ba1 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointConnectionListResult.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointConnectionListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// The response of a PrivateEndpointConnection list operation. internal partial class GrafanaPrivateEndpointConnectionListResult { - /// - /// 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 PrivateEndpointConnection items on this page. - /// is null. internal GrafanaPrivateEndpointConnectionListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The PrivateEndpointConnection items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal GrafanaPrivateEndpointConnectionListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaPrivateEndpointConnectionListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal GrafanaPrivateEndpointConnectionListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The PrivateEndpointConnection 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointConnectionProvisioningState.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointConnectionProvisioningState.cs index 9574347c92fe..3923af8aac49 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointConnectionProvisioningState.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointConnectionProvisioningState.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { @@ -14,44 +15,67 @@ namespace Azure.ResourceManager.Grafana.Models public readonly partial struct GrafanaPrivateEndpointConnectionProvisioningState : IEquatable { private readonly string _value; + /// Connection has been provisioned. + private const string SucceededValue = "Succeeded"; + /// Connection is being created. + private const string CreatingValue = "Creating"; + /// Connection is being deleted. + private const string DeletingValue = "Deleting"; + /// Connection provisioning has failed. + private const string FailedValue = "Failed"; /// Initializes a new instance of . + /// The value. /// is null. public GrafanaPrivateEndpointConnectionProvisioningState(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SucceededValue = "Succeeded"; - private const string CreatingValue = "Creating"; - private const string DeletingValue = "Deleting"; - private const string FailedValue = "Failed"; + _value = value; + } /// Connection has been provisioned. public static GrafanaPrivateEndpointConnectionProvisioningState Succeeded { get; } = new GrafanaPrivateEndpointConnectionProvisioningState(SucceededValue); + /// Connection is being created. public static GrafanaPrivateEndpointConnectionProvisioningState Creating { get; } = new GrafanaPrivateEndpointConnectionProvisioningState(CreatingValue); + /// Connection is being deleted. public static GrafanaPrivateEndpointConnectionProvisioningState Deleting { get; } = new GrafanaPrivateEndpointConnectionProvisioningState(DeletingValue); + /// Connection provisioning has failed. public static GrafanaPrivateEndpointConnectionProvisioningState Failed { get; } = new GrafanaPrivateEndpointConnectionProvisioningState(FailedValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(GrafanaPrivateEndpointConnectionProvisioningState left, GrafanaPrivateEndpointConnectionProvisioningState 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 !=(GrafanaPrivateEndpointConnectionProvisioningState left, GrafanaPrivateEndpointConnectionProvisioningState right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator GrafanaPrivateEndpointConnectionProvisioningState(string value) => new GrafanaPrivateEndpointConnectionProvisioningState(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator GrafanaPrivateEndpointConnectionProvisioningState?(string value) => value == null ? null : new GrafanaPrivateEndpointConnectionProvisioningState(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is GrafanaPrivateEndpointConnectionProvisioningState other && Equals(other); - /// + + /// public bool Equals(GrafanaPrivateEndpointConnectionProvisioningState 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointServiceConnectionStatus.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointServiceConnectionStatus.cs index 9906187ede71..d86b21d77158 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointServiceConnectionStatus.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateEndpointServiceConnectionStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { @@ -14,41 +15,62 @@ namespace Azure.ResourceManager.Grafana.Models public readonly partial struct GrafanaPrivateEndpointServiceConnectionStatus : IEquatable { private readonly string _value; + /// Connection waiting for approval or rejection. + private const string PendingValue = "Pending"; + /// Connection approved. + private const string ApprovedValue = "Approved"; + /// Connection Rejected. + private const string RejectedValue = "Rejected"; /// Initializes a new instance of . + /// The value. /// is null. public GrafanaPrivateEndpointServiceConnectionStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string PendingValue = "Pending"; - private const string ApprovedValue = "Approved"; - private const string RejectedValue = "Rejected"; + _value = value; + } /// Connection waiting for approval or rejection. public static GrafanaPrivateEndpointServiceConnectionStatus Pending { get; } = new GrafanaPrivateEndpointServiceConnectionStatus(PendingValue); + /// Connection approved. public static GrafanaPrivateEndpointServiceConnectionStatus Approved { get; } = new GrafanaPrivateEndpointServiceConnectionStatus(ApprovedValue); + /// Connection Rejected. public static GrafanaPrivateEndpointServiceConnectionStatus Rejected { get; } = new GrafanaPrivateEndpointServiceConnectionStatus(RejectedValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(GrafanaPrivateEndpointServiceConnectionStatus left, GrafanaPrivateEndpointServiceConnectionStatus 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 !=(GrafanaPrivateEndpointServiceConnectionStatus left, GrafanaPrivateEndpointServiceConnectionStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator GrafanaPrivateEndpointServiceConnectionStatus(string value) => new GrafanaPrivateEndpointServiceConnectionStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator GrafanaPrivateEndpointServiceConnectionStatus?(string value) => value == null ? null : new GrafanaPrivateEndpointServiceConnectionStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is GrafanaPrivateEndpointServiceConnectionStatus other && Equals(other); - /// + + /// public bool Equals(GrafanaPrivateEndpointServiceConnectionStatus 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceListResult.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceListResult.Serialization.cs index 26bef366d0a6..5f29f820ddca 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceListResult.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceListResult.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.Grafana; namespace Azure.ResourceManager.Grafana.Models { - internal partial class GrafanaPrivateLinkResourceListResult : IUtf8JsonSerializable, IJsonModel + /// The response of a PrivateLinkResource list operation. + internal partial class GrafanaPrivateLinkResourceListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal GrafanaPrivateLinkResourceListResult() + { + } + /// 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 write /// 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(GrafanaPrivateLinkResourceListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (GrafanaPrivateLinkResourceData 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 } } - GrafanaPrivateLinkResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaPrivateLinkResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaPrivateLinkResourceListResult 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(GrafanaPrivateLinkResourceListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaPrivateLinkResourceListResult(document.RootElement, options); } - internal static GrafanaPrivateLinkResourceListResult DeserializeGrafanaPrivateLinkResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaPrivateLinkResourceListResult DeserializeGrafanaPrivateLinkResourceListResult(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(GrafanaPrivateLinkResourceData.DeserializeGrafanaPrivateLinkResourceData(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 GrafanaPrivateLinkResourceListResult(value, nextLink, serializedAdditionalRawData); + return new GrafanaPrivateLinkResourceListResult(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(ModelRe } } - GrafanaPrivateLinkResourceListResult 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. + GrafanaPrivateLinkResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaPrivateLinkResourceListResult 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 DeserializeGrafanaPrivateLinkResourceListResult(document.RootElement, options); } default: @@ -146,6 +163,14 @@ GrafanaPrivateLinkResourceListResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static GrafanaPrivateLinkResourceListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGrafanaPrivateLinkResourceListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceListResult.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceListResult.cs index 3869d366ce62..2ac196b804ca 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceListResult.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// The response of a PrivateLinkResource list operation. internal partial class GrafanaPrivateLinkResourceListResult { - /// - /// 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 PrivateLinkResource items on this page. - /// is null. internal GrafanaPrivateLinkResourceListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The PrivateLinkResource items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal GrafanaPrivateLinkResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaPrivateLinkResourceListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal GrafanaPrivateLinkResourceListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The PrivateLinkResource 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceProperties.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceProperties.Serialization.cs new file mode 100644 index 000000000000..fe94530121ab --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceProperties.Serialization.cs @@ -0,0 +1,230 @@ +// 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.Grafana; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// Properties of a private link resource. + internal partial class GrafanaPrivateLinkResourceProperties : 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(GrafanaPrivateLinkResourceProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(GroupId)) + { + writer.WritePropertyName("groupId"u8); + writer.WriteStringValue(GroupId); + } + if (options.Format != "W" && Optional.IsCollectionDefined(RequiredMembers)) + { + writer.WritePropertyName("requiredMembers"u8); + writer.WriteStartArray(); + foreach (string item in RequiredMembers) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(RequiredZoneNames)) + { + writer.WritePropertyName("requiredZoneNames"u8); + writer.WriteStartArray(); + foreach (string item in RequiredZoneNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaPrivateLinkResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaPrivateLinkResourceProperties 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(GrafanaPrivateLinkResourceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGrafanaPrivateLinkResourceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaPrivateLinkResourceProperties DeserializeGrafanaPrivateLinkResourceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + GrafanaProvisioningState? provisioningState = default; + string groupId = default; + IReadOnlyList requiredMembers = default; + IList requiredZoneNames = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new GrafanaProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("groupId"u8)) + { + groupId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("requiredMembers"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + requiredMembers = array; + continue; + } + if (prop.NameEquals("requiredZoneNames"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + requiredZoneNames = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new GrafanaPrivateLinkResourceProperties(provisioningState, groupId, requiredMembers ?? new ChangeTrackingList(), requiredZoneNames ?? 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, AzureResourceManagerGrafanaContext.Default); + default: + throw new FormatException($"The model {nameof(GrafanaPrivateLinkResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + GrafanaPrivateLinkResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaPrivateLinkResourceProperties 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 DeserializeGrafanaPrivateLinkResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GrafanaPrivateLinkResourceProperties)} 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceProperties.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceProperties.cs new file mode 100644 index 000000000000..81167381088b --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkResourceProperties.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.Grafana; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// Properties of a private link resource. + internal partial class GrafanaPrivateLinkResourceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal GrafanaPrivateLinkResourceProperties() + { + RequiredMembers = new ChangeTrackingList(); + RequiredZoneNames = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Provisioning state of the resource. + /// The private link resource group id. + /// The private link resource required member names. + /// The private link resource Private link DNS zone name. + /// Keeps track of any properties unknown to the library. + internal GrafanaPrivateLinkResourceProperties(GrafanaProvisioningState? provisioningState, string groupId, IReadOnlyList requiredMembers, IList requiredZoneNames, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + GroupId = groupId; + RequiredMembers = requiredMembers; + RequiredZoneNames = requiredZoneNames; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Provisioning state of the resource. + public GrafanaProvisioningState? ProvisioningState { get; } + + /// The private link resource group id. + public string GroupId { get; } + + /// The private link resource required member names. + public IReadOnlyList RequiredMembers { get; } = new ChangeTrackingList(); + + /// The private link resource Private link DNS zone name. + public IList RequiredZoneNames { get; } = new ChangeTrackingList(); + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkServiceConnectionState.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkServiceConnectionState.Serialization.cs index 208df4dbabd3..0a2026abb70c 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkServiceConnectionState.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkServiceConnectionState.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class GrafanaPrivateLinkServiceConnectionState : IUtf8JsonSerializable, IJsonModel + /// A collection of information about the state of the connection between service consumer and provider. + public partial class GrafanaPrivateLinkServiceConnectionState : 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 w /// 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(GrafanaPrivateLinkServiceConnectionState)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Status)) { writer.WritePropertyName("status"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("actionsRequired"u8); writer.WriteStringValue(ActionsRequired); } - 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 } } - GrafanaPrivateLinkServiceConnectionState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaPrivateLinkServiceConnectionState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaPrivateLinkServiceConnectionState 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(GrafanaPrivateLinkServiceConnectionState)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaPrivateLinkServiceConnectionState(document.RootElement, options); } - internal static GrafanaPrivateLinkServiceConnectionState DeserializeGrafanaPrivateLinkServiceConnectionState(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaPrivateLinkServiceConnectionState DeserializeGrafanaPrivateLinkServiceConnectionState(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,42 +94,43 @@ internal static GrafanaPrivateLinkServiceConnectionState DeserializeGrafanaPriva GrafanaPrivateEndpointServiceConnectionStatus? status = default; string description = default; string actionsRequired = 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("status"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - status = new GrafanaPrivateEndpointServiceConnectionStatus(property.Value.GetString()); + status = new GrafanaPrivateEndpointServiceConnectionStatus(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("actionsRequired"u8)) + if (prop.NameEquals("actionsRequired"u8)) { - actionsRequired = property.Value.GetString(); + actionsRequired = 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 GrafanaPrivateLinkServiceConnectionState(status, description, actionsRequired, serializedAdditionalRawData); + return new GrafanaPrivateLinkServiceConnectionState(status, description, actionsRequired, 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(Mod } } - GrafanaPrivateLinkServiceConnectionState 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. + GrafanaPrivateLinkServiceConnectionState IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaPrivateLinkServiceConnectionState 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 DeserializeGrafanaPrivateLinkServiceConnectionState(document.RootElement, options); } default: @@ -150,6 +161,7 @@ GrafanaPrivateLinkServiceConnectionState IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkServiceConnectionState.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkServiceConnectionState.cs index 81ee5d2e06c0..f5ed4e9bd029 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkServiceConnectionState.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPrivateLinkServiceConnectionState.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.Grafana.Models /// A collection of information about the state of the connection between service consumer and provider. public partial class GrafanaPrivateLinkServiceConnectionState { - /// - /// 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 GrafanaPrivateLinkServiceConnectionState() @@ -54,19 +25,21 @@ public GrafanaPrivateLinkServiceConnectionState() /// Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. /// The reason for approval/rejection of the connection. /// A message indicating if changes on the service provider require any updates on the consumer. - /// Keeps track of any properties unknown to the library. - internal GrafanaPrivateLinkServiceConnectionState(GrafanaPrivateEndpointServiceConnectionStatus? status, string description, string actionsRequired, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaPrivateLinkServiceConnectionState(GrafanaPrivateEndpointServiceConnectionStatus? status, string description, string actionsRequired, IDictionary additionalBinaryDataProperties) { Status = status; Description = description; ActionsRequired = actionsRequired; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. public GrafanaPrivateEndpointServiceConnectionStatus? Status { get; set; } + /// The reason for approval/rejection of the connection. public string Description { get; set; } + /// A message indicating if changes on the service provider require any updates on the consumer. public string ActionsRequired { get; set; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaProvisioningState.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaProvisioningState.cs index 7312672bc036..5e099ce59edc 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaProvisioningState.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaProvisioningState.cs @@ -7,21 +7,14 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - /// The GrafanaProvisioningState. + /// public readonly partial struct GrafanaProvisioningState : IEquatable { private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public GrafanaProvisioningState(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - private const string AcceptedValue = "Accepted"; private const string CreatingValue = "Creating"; private const string UpdatingValue = "Updating"; @@ -32,41 +25,73 @@ public GrafanaProvisioningState(string value) private const string DeletedValue = "Deleted"; private const string NotSpecifiedValue = "NotSpecified"; - /// Accepted. + /// Initializes a new instance of . + /// The value. + /// is null. + public GrafanaProvisioningState(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Accepted. public static GrafanaProvisioningState Accepted { get; } = new GrafanaProvisioningState(AcceptedValue); - /// Creating. + + /// Gets the Creating. public static GrafanaProvisioningState Creating { get; } = new GrafanaProvisioningState(CreatingValue); - /// Updating. + + /// Gets the Updating. public static GrafanaProvisioningState Updating { get; } = new GrafanaProvisioningState(UpdatingValue); - /// Deleting. + + /// Gets the Deleting. public static GrafanaProvisioningState Deleting { get; } = new GrafanaProvisioningState(DeletingValue); - /// Succeeded. + + /// Gets the Succeeded. public static GrafanaProvisioningState Succeeded { get; } = new GrafanaProvisioningState(SucceededValue); - /// Failed. + + /// Gets the Failed. public static GrafanaProvisioningState Failed { get; } = new GrafanaProvisioningState(FailedValue); - /// Canceled. + + /// Gets the Canceled. public static GrafanaProvisioningState Canceled { get; } = new GrafanaProvisioningState(CanceledValue); - /// Deleted. + + /// Gets the Deleted. public static GrafanaProvisioningState Deleted { get; } = new GrafanaProvisioningState(DeletedValue); - /// NotSpecified. + + /// Gets the NotSpecified. public static GrafanaProvisioningState NotSpecified { get; } = new GrafanaProvisioningState(NotSpecifiedValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(GrafanaProvisioningState left, GrafanaProvisioningState 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 !=(GrafanaProvisioningState left, GrafanaProvisioningState right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator GrafanaProvisioningState(string value) => new GrafanaProvisioningState(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator GrafanaProvisioningState?(string value) => value == null ? null : new GrafanaProvisioningState(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is GrafanaProvisioningState other && Equals(other); - /// + + /// public bool Equals(GrafanaProvisioningState 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPublicNetworkAccess.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPublicNetworkAccess.cs index 270a580f00f4..429ca3222dd4 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPublicNetworkAccess.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaPublicNetworkAccess.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { @@ -14,38 +15,55 @@ namespace Azure.ResourceManager.Grafana.Models public readonly partial struct GrafanaPublicNetworkAccess : IEquatable { private readonly string _value; + private const string EnabledValue = "Enabled"; + private const string DisabledValue = "Disabled"; /// Initializes a new instance of . + /// The value. /// is null. public GrafanaPublicNetworkAccess(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string EnabledValue = "Enabled"; - private const string DisabledValue = "Disabled"; + _value = value; + } - /// Enabled. + /// Gets the Enabled. public static GrafanaPublicNetworkAccess Enabled { get; } = new GrafanaPublicNetworkAccess(EnabledValue); - /// Disabled. + + /// Gets the Disabled. public static GrafanaPublicNetworkAccess Disabled { get; } = new GrafanaPublicNetworkAccess(DisabledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(GrafanaPublicNetworkAccess left, GrafanaPublicNetworkAccess 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 !=(GrafanaPublicNetworkAccess left, GrafanaPublicNetworkAccess right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator GrafanaPublicNetworkAccess(string value) => new GrafanaPublicNetworkAccess(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator GrafanaPublicNetworkAccess?(string value) => value == null ? null : new GrafanaPublicNetworkAccess(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is GrafanaPublicNetworkAccess other && Equals(other); - /// + + /// public bool Equals(GrafanaPublicNetworkAccess 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSecuritySettings.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSecuritySettings.Serialization.cs index ba0c06ef5acd..94a5e8ea5d60 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSecuritySettings.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSecuritySettings.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - internal partial class GrafanaSecuritySettings : IUtf8JsonSerializable, IJsonModel + /// Grafana security settings. + internal partial class GrafanaSecuritySettings : 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 +29,25 @@ 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(GrafanaSecuritySettings)} does not support writing '{format}' format."); } - if (Optional.IsDefined(IsCsrfAlwaysCheckEnabled)) { writer.WritePropertyName("csrfAlwaysCheck"u8); writer.WriteBooleanValue(IsCsrfAlwaysCheckEnabled.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); } @@ -56,53 +56,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - GrafanaSecuritySettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaSecuritySettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaSecuritySettings 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(GrafanaSecuritySettings)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaSecuritySettings(document.RootElement, options); } - internal static GrafanaSecuritySettings DeserializeGrafanaSecuritySettings(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaSecuritySettings DeserializeGrafanaSecuritySettings(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - bool? csrfAlwaysCheck = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + bool? isCsrfAlwaysCheckEnabled = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("csrfAlwaysCheck"u8)) + if (prop.NameEquals("csrfAlwaysCheck"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - csrfAlwaysCheck = property.Value.GetBoolean(); + isCsrfAlwaysCheckEnabled = prop.Value.GetBoolean(); 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 GrafanaSecuritySettings(csrfAlwaysCheck, serializedAdditionalRawData); + return new GrafanaSecuritySettings(isCsrfAlwaysCheckEnabled, 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": @@ -112,15 +118,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt } } - GrafanaSecuritySettings 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. + GrafanaSecuritySettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaSecuritySettings 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 DeserializeGrafanaSecuritySettings(document.RootElement, options); } default: @@ -128,6 +139,7 @@ GrafanaSecuritySettings IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSecuritySettings.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSecuritySettings.cs index ae4cd1351508..dc7c32690ec9 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSecuritySettings.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSecuritySettings.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.Grafana.Models /// Grafana security settings. internal partial class GrafanaSecuritySettings { - /// - /// 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 GrafanaSecuritySettings() @@ -52,11 +23,11 @@ public GrafanaSecuritySettings() /// Initializes a new instance of . /// Set to true to execute the CSRF check even if the login cookie is not in a request (default false). - /// Keeps track of any properties unknown to the library. - internal GrafanaSecuritySettings(bool? isCsrfAlwaysCheckEnabled, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaSecuritySettings(bool? isCsrfAlwaysCheckEnabled, IDictionary additionalBinaryDataProperties) { IsCsrfAlwaysCheckEnabled = isCsrfAlwaysCheckEnabled; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Set to true to execute the CSRF check even if the login cookie is not in a request (default false). diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSize.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSize.cs index a1621b4df2f1..e876d75f003d 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSize.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSize.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { @@ -14,38 +15,57 @@ namespace Azure.ResourceManager.Grafana.Models public readonly partial struct GrafanaSize : IEquatable { private readonly string _value; + /// X1 capacity tier. + private const string X1Value = "X1"; + /// X2 capacity tier. + private const string X2Value = "X2"; /// Initializes a new instance of . + /// The value. /// is null. public GrafanaSize(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string X1Value = "X1"; - private const string X2Value = "X2"; + _value = value; + } /// X1 capacity tier. public static GrafanaSize X1 { get; } = new GrafanaSize(X1Value); + /// X2 capacity tier. public static GrafanaSize X2 { get; } = new GrafanaSize(X2Value); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(GrafanaSize left, GrafanaSize 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 !=(GrafanaSize left, GrafanaSize right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator GrafanaSize(string value) => new GrafanaSize(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator GrafanaSize?(string value) => value == null ? null : new GrafanaSize(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is GrafanaSize other && Equals(other); - /// + + /// public bool Equals(GrafanaSize 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSmtpSettings.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSmtpSettings.Serialization.cs index 5b4c6fb1de06..a88ebd4ef533 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSmtpSettings.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSmtpSettings.Serialization.cs @@ -9,14 +9,18 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class GrafanaSmtpSettings : IUtf8JsonSerializable, IJsonModel + /// + /// Email server settings. + /// https://grafana.com/docs/grafana/v9.0/setup-grafana/configure-grafana/#smtp + /// + public partial class GrafanaSmtpSettings : 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 +32,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(GrafanaSmtpSettings)} does not support writing '{format}' format."); } - if (Optional.IsDefined(IsEnabled)) { writer.WritePropertyName("enabled"u8); @@ -74,15 +77,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("skipVerify"u8); writer.WriteBooleanValue(SkipVerify.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); } @@ -91,27 +94,32 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - GrafanaSmtpSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaSmtpSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaSmtpSettings 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(GrafanaSmtpSettings)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaSmtpSettings(document.RootElement, options); } - internal static GrafanaSmtpSettings DeserializeGrafanaSmtpSettings(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaSmtpSettings DeserializeGrafanaSmtpSettings(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - bool? enabled = default; + bool? isEnabled = default; string host = default; string user = default; string password = default; @@ -119,70 +127,68 @@ internal static GrafanaSmtpSettings DeserializeGrafanaSmtpSettings(JsonElement e string fromName = default; GrafanaStartTlsPolicy? startTLSPolicy = default; bool? skipVerify = 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("enabled"u8)) + if (prop.NameEquals("enabled"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - enabled = property.Value.GetBoolean(); + isEnabled = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("host"u8)) + if (prop.NameEquals("host"u8)) { - host = property.Value.GetString(); + host = prop.Value.GetString(); continue; } - if (property.NameEquals("user"u8)) + if (prop.NameEquals("user"u8)) { - user = property.Value.GetString(); + user = prop.Value.GetString(); continue; } - if (property.NameEquals("password"u8)) + if (prop.NameEquals("password"u8)) { - password = property.Value.GetString(); + password = prop.Value.GetString(); continue; } - if (property.NameEquals("fromAddress"u8)) + if (prop.NameEquals("fromAddress"u8)) { - fromAddress = property.Value.GetString(); + fromAddress = prop.Value.GetString(); continue; } - if (property.NameEquals("fromName"u8)) + if (prop.NameEquals("fromName"u8)) { - fromName = property.Value.GetString(); + fromName = prop.Value.GetString(); continue; } - if (property.NameEquals("startTLSPolicy"u8)) + if (prop.NameEquals("startTLSPolicy"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - startTLSPolicy = new GrafanaStartTlsPolicy(property.Value.GetString()); + startTLSPolicy = new GrafanaStartTlsPolicy(prop.Value.GetString()); continue; } - if (property.NameEquals("skipVerify"u8)) + if (prop.NameEquals("skipVerify"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - skipVerify = property.Value.GetBoolean(); + skipVerify = prop.Value.GetBoolean(); 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 GrafanaSmtpSettings( - enabled, + isEnabled, host, user, password, @@ -190,13 +196,16 @@ internal static GrafanaSmtpSettings DeserializeGrafanaSmtpSettings(JsonElement e fromName, startTLSPolicy, skipVerify, - 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 +215,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - GrafanaSmtpSettings 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. + GrafanaSmtpSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaSmtpSettings 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 DeserializeGrafanaSmtpSettings(document.RootElement, options); } default: @@ -222,6 +236,7 @@ GrafanaSmtpSettings IPersistableModel.Create(BinaryData dat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSmtpSettings.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSmtpSettings.cs index aeff703e5f9d..4875ecb44e21 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSmtpSettings.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSmtpSettings.cs @@ -16,37 +16,8 @@ namespace Azure.ResourceManager.Grafana.Models /// public partial class GrafanaSmtpSettings { - /// - /// 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 GrafanaSmtpSettings() @@ -74,8 +45,8 @@ public GrafanaSmtpSettings() /// Verify SSL for SMTP server. Default is false /// https://pkg.go.dev/crypto/tls#Config /// - /// Keeps track of any properties unknown to the library. - internal GrafanaSmtpSettings(bool? isEnabled, string host, string user, string password, string fromAddress, string fromName, GrafanaStartTlsPolicy? startTLSPolicy, bool? skipVerify, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaSmtpSettings(bool? isEnabled, string host, string user, string password, string fromAddress, string fromName, GrafanaStartTlsPolicy? startTLSPolicy, bool? skipVerify, IDictionary additionalBinaryDataProperties) { IsEnabled = isEnabled; Host = host; @@ -85,32 +56,39 @@ internal GrafanaSmtpSettings(bool? isEnabled, string host, string user, string p FromName = fromName; StartTLSPolicy = startTLSPolicy; SkipVerify = skipVerify; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Enable this to allow Grafana to send email. Default is false. public bool? IsEnabled { get; set; } + /// SMTP server hostname with port, e.g. test.email.net:587. public string Host { get; set; } + /// User of SMTP auth. public string User { get; set; } + /// Password of SMTP auth. If the password contains # or ;, then you have to wrap it with triple quotes. public string Password { get; set; } + /// /// Address used when sending out emails /// https://pkg.go.dev/net/mail#Address /// public string FromAddress { get; set; } + /// /// Name to be used when sending out emails. Default is "Azure Managed Grafana Notification" /// https://pkg.go.dev/net/mail#Address /// public string FromName { get; set; } + /// /// The StartTLSPolicy setting of the SMTP configuration /// https://pkg.go.dev/github.com/go-mail/mail#StartTLSPolicy /// public GrafanaStartTlsPolicy? StartTLSPolicy { get; set; } + /// /// Verify SSL for SMTP server. Default is false /// https://pkg.go.dev/crypto/tls#Config diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSnapshotsSettings.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSnapshotsSettings.Serialization.cs index a0ac91386a96..b9fadebed95f 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSnapshotsSettings.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSnapshotsSettings.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - internal partial class GrafanaSnapshotsSettings : IUtf8JsonSerializable, IJsonModel + /// Grafana Snapshots settings. + internal partial class GrafanaSnapshotsSettings : 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 +29,25 @@ 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(GrafanaSnapshotsSettings)} does not support writing '{format}' format."); } - if (Optional.IsDefined(IsExternalEnabled)) { writer.WritePropertyName("externalEnabled"u8); writer.WriteBooleanValue(IsExternalEnabled.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); } @@ -56,53 +56,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - GrafanaSnapshotsSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaSnapshotsSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaSnapshotsSettings 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(GrafanaSnapshotsSettings)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaSnapshotsSettings(document.RootElement, options); } - internal static GrafanaSnapshotsSettings DeserializeGrafanaSnapshotsSettings(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaSnapshotsSettings DeserializeGrafanaSnapshotsSettings(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - bool? externalEnabled = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + bool? isExternalEnabled = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("externalEnabled"u8)) + if (prop.NameEquals("externalEnabled"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - externalEnabled = property.Value.GetBoolean(); + isExternalEnabled = prop.Value.GetBoolean(); 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 GrafanaSnapshotsSettings(externalEnabled, serializedAdditionalRawData); + return new GrafanaSnapshotsSettings(isExternalEnabled, 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": @@ -112,15 +118,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp } } - GrafanaSnapshotsSettings 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. + GrafanaSnapshotsSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaSnapshotsSettings 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 DeserializeGrafanaSnapshotsSettings(document.RootElement, options); } default: @@ -128,6 +139,7 @@ GrafanaSnapshotsSettings IPersistableModel.Create(Bina } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSnapshotsSettings.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSnapshotsSettings.cs index ddbcd3e3b568..b193f7fdf4ad 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSnapshotsSettings.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaSnapshotsSettings.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.Grafana.Models /// Grafana Snapshots settings. internal partial class GrafanaSnapshotsSettings { - /// - /// 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 GrafanaSnapshotsSettings() @@ -52,11 +23,11 @@ public GrafanaSnapshotsSettings() /// Initializes a new instance of . /// Set to false to disable external snapshot publish endpoint. - /// Keeps track of any properties unknown to the library. - internal GrafanaSnapshotsSettings(bool? isExternalEnabled, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaSnapshotsSettings(bool? isExternalEnabled, IDictionary additionalBinaryDataProperties) { IsExternalEnabled = isExternalEnabled; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Set to false to disable external snapshot publish endpoint. diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaStartTlsPolicy.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaStartTlsPolicy.cs index d609268e6e8f..928f1ab29bd8 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaStartTlsPolicy.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaStartTlsPolicy.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { @@ -17,41 +18,59 @@ namespace Azure.ResourceManager.Grafana.Models public readonly partial struct GrafanaStartTlsPolicy : IEquatable { private readonly string _value; + private const string OpportunisticStartTlsValue = "OpportunisticStartTLS"; + private const string MandatoryStartTlsValue = "MandatoryStartTLS"; + private const string NoStartTlsValue = "NoStartTLS"; /// Initializes a new instance of . + /// The value. /// is null. public GrafanaStartTlsPolicy(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string OpportunisticStartTlsValue = "OpportunisticStartTLS"; - private const string MandatoryStartTlsValue = "MandatoryStartTLS"; - private const string NoStartTlsValue = "NoStartTLS"; + _value = value; + } - /// OpportunisticStartTLS. + /// Gets the OpportunisticStartTls. public static GrafanaStartTlsPolicy OpportunisticStartTls { get; } = new GrafanaStartTlsPolicy(OpportunisticStartTlsValue); - /// MandatoryStartTLS. + + /// Gets the MandatoryStartTls. public static GrafanaStartTlsPolicy MandatoryStartTls { get; } = new GrafanaStartTlsPolicy(MandatoryStartTlsValue); - /// NoStartTLS. + + /// Gets the NoStartTls. public static GrafanaStartTlsPolicy NoStartTls { get; } = new GrafanaStartTlsPolicy(NoStartTlsValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(GrafanaStartTlsPolicy left, GrafanaStartTlsPolicy 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 !=(GrafanaStartTlsPolicy left, GrafanaStartTlsPolicy right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator GrafanaStartTlsPolicy(string value) => new GrafanaStartTlsPolicy(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator GrafanaStartTlsPolicy?(string value) => value == null ? null : new GrafanaStartTlsPolicy(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is GrafanaStartTlsPolicy other && Equals(other); - /// + + /// public bool Equals(GrafanaStartTlsPolicy 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaUserSettings.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaUserSettings.Serialization.cs index c0de83838c77..9db96c31e3b1 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaUserSettings.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaUserSettings.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class GrafanaUserSettings : IUtf8JsonSerializable, IJsonModel + /// Grafana users settings. + public partial class GrafanaUserSettings : 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(GrafanaUserSettings)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ViewersCanEdit)) { writer.WritePropertyName("viewersCanEdit"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("editorsCanAdmin"u8); writer.WriteBooleanValue(EditorsCanAdmin.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,63 +61,69 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - GrafanaUserSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GrafanaUserSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GrafanaUserSettings 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(GrafanaUserSettings)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGrafanaUserSettings(document.RootElement, options); } - internal static GrafanaUserSettings DeserializeGrafanaUserSettings(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GrafanaUserSettings DeserializeGrafanaUserSettings(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } bool? viewersCanEdit = default; bool? editorsCanAdmin = 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("viewersCanEdit"u8)) + if (prop.NameEquals("viewersCanEdit"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - viewersCanEdit = property.Value.GetBoolean(); + viewersCanEdit = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("editorsCanAdmin"u8)) + if (prop.NameEquals("editorsCanAdmin"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - editorsCanAdmin = property.Value.GetBoolean(); + editorsCanAdmin = prop.Value.GetBoolean(); 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 GrafanaUserSettings(viewersCanEdit, editorsCanAdmin, serializedAdditionalRawData); + return new GrafanaUserSettings(viewersCanEdit, editorsCanAdmin, 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": @@ -127,15 +133,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - GrafanaUserSettings 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. + GrafanaUserSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GrafanaUserSettings 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 DeserializeGrafanaUserSettings(document.RootElement, options); } default: @@ -143,6 +154,7 @@ GrafanaUserSettings IPersistableModel.Create(BinaryData dat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaUserSettings.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaUserSettings.cs index 0cfcb8e130b1..b8597eef6ae8 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaUserSettings.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaUserSettings.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.Grafana.Models /// Grafana users settings. public partial class GrafanaUserSettings { - /// - /// 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 GrafanaUserSettings() @@ -53,16 +24,17 @@ public GrafanaUserSettings() /// Initializes a new instance of . /// Set to true so viewers can access and use explore and perform temporary edits on panels in dashboards they have access to. They cannot save their changes. /// Set to true so editors can administrate dashboards, folders and teams they create. - /// Keeps track of any properties unknown to the library. - internal GrafanaUserSettings(bool? viewersCanEdit, bool? editorsCanAdmin, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GrafanaUserSettings(bool? viewersCanEdit, bool? editorsCanAdmin, IDictionary additionalBinaryDataProperties) { ViewersCanEdit = viewersCanEdit; EditorsCanAdmin = editorsCanAdmin; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Set to true so viewers can access and use explore and perform temporary edits on panels in dashboards they have access to. They cannot save their changes. public bool? ViewersCanEdit { get; set; } + /// Set to true so editors can administrate dashboards, folders and teams they create. public bool? EditorsCanAdmin { get; set; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaZoneRedundancy.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaZoneRedundancy.cs index 7fc57c046743..1da7ee4facb4 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaZoneRedundancy.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/GrafanaZoneRedundancy.cs @@ -7,45 +7,63 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - /// The GrafanaZoneRedundancy. + /// public readonly partial struct GrafanaZoneRedundancy : IEquatable { private readonly string _value; + private const string DisabledValue = "Disabled"; + private const string EnabledValue = "Enabled"; /// Initializes a new instance of . + /// The value. /// is null. public GrafanaZoneRedundancy(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string DisabledValue = "Disabled"; - private const string EnabledValue = "Enabled"; + _value = value; + } - /// Disabled. + /// Gets the Disabled. public static GrafanaZoneRedundancy Disabled { get; } = new GrafanaZoneRedundancy(DisabledValue); - /// Enabled. + + /// Gets the Enabled. public static GrafanaZoneRedundancy Enabled { get; } = new GrafanaZoneRedundancy(EnabledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(GrafanaZoneRedundancy left, GrafanaZoneRedundancy 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 !=(GrafanaZoneRedundancy left, GrafanaZoneRedundancy right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator GrafanaZoneRedundancy(string value) => new GrafanaZoneRedundancy(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator GrafanaZoneRedundancy?(string value) => value == null ? null : new GrafanaZoneRedundancy(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is GrafanaZoneRedundancy other && Equals(other); - /// + + /// public bool Equals(GrafanaZoneRedundancy 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricListResponse.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricListResponse.Serialization.cs index 253dbb37b8a4..35bd5f188cd1 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricListResponse.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricListResponse.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.Grafana; namespace Azure.ResourceManager.Grafana.Models { - internal partial class IntegrationFabricListResponse : IUtf8JsonSerializable, IJsonModel + /// Paged collection of IntegrationFabric items. + internal partial class IntegrationFabricListResponse : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal IntegrationFabricListResponse() + { + } + /// 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, 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(IntegrationFabricListResponse)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (GrafanaIntegrationFabricData 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 } } - IntegrationFabricListResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + IntegrationFabricListResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual IntegrationFabricListResponse 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(IntegrationFabricListResponse)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeIntegrationFabricListResponse(document.RootElement, options); } - internal static IntegrationFabricListResponse DeserializeIntegrationFabricListResponse(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static IntegrationFabricListResponse DeserializeIntegrationFabricListResponse(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(GrafanaIntegrationFabricData.DeserializeGrafanaIntegrationFabricData(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 IntegrationFabricListResponse(value, nextLink, serializedAdditionalRawData); + return new IntegrationFabricListResponse(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(ModelReaderWri } } - IntegrationFabricListResponse 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. + IntegrationFabricListResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual IntegrationFabricListResponse 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 DeserializeIntegrationFabricListResponse(document.RootElement, options); } default: @@ -146,6 +163,14 @@ IntegrationFabricListResponse IPersistableModel.C } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static IntegrationFabricListResponse FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeIntegrationFabricListResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricListResponse.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricListResponse.cs index 4bdee87c2ef5..34b68042e450 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricListResponse.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricListResponse.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// Paged collection of IntegrationFabric items. internal partial class IntegrationFabricListResponse { - /// - /// 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 IntegrationFabric items on this page. - /// is null. internal IntegrationFabricListResponse(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The IntegrationFabric items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal IntegrationFabricListResponse(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal IntegrationFabricListResponse(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal IntegrationFabricListResponse() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The IntegrationFabric 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricPropertiesUpdateParameters.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricPropertiesUpdateParameters.Serialization.cs index d44e72ba1ecf..ddf43f171d0b 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricPropertiesUpdateParameters.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricPropertiesUpdateParameters.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - internal partial class IntegrationFabricPropertiesUpdateParameters : IUtf8JsonSerializable, IJsonModel + /// The IntegrationFabricPropertiesUpdateParameters. + internal partial class IntegrationFabricPropertiesUpdateParameters : 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,35 @@ void IJsonModel.Write(Utf8JsonWrite /// 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(IntegrationFabricPropertiesUpdateParameters)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Scenarios)) { writer.WritePropertyName("scenarios"u8); writer.WriteStartArray(); - foreach (var item in Scenarios) + foreach (string item in Scenarios) { + 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); } @@ -61,58 +66,71 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - IntegrationFabricPropertiesUpdateParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + IntegrationFabricPropertiesUpdateParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual IntegrationFabricPropertiesUpdateParameters 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(IntegrationFabricPropertiesUpdateParameters)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeIntegrationFabricPropertiesUpdateParameters(document.RootElement, options); } - internal static IntegrationFabricPropertiesUpdateParameters DeserializeIntegrationFabricPropertiesUpdateParameters(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static IntegrationFabricPropertiesUpdateParameters DeserializeIntegrationFabricPropertiesUpdateParameters(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IList scenarios = 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("scenarios"u8)) + if (prop.NameEquals("scenarios"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()); + } } scenarios = 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 IntegrationFabricPropertiesUpdateParameters(scenarios ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new IntegrationFabricPropertiesUpdateParameters(scenarios ?? 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 +140,20 @@ BinaryData IPersistableModel.Write( } } - IntegrationFabricPropertiesUpdateParameters 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. + IntegrationFabricPropertiesUpdateParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual IntegrationFabricPropertiesUpdateParameters 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 DeserializeIntegrationFabricPropertiesUpdateParameters(document.RootElement, options); } default: @@ -138,6 +161,7 @@ IntegrationFabricPropertiesUpdateParameters IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricPropertiesUpdateParameters.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricPropertiesUpdateParameters.cs index f170c39b6005..964c93ea90fe 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricPropertiesUpdateParameters.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/IntegrationFabricPropertiesUpdateParameters.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// The IntegrationFabricPropertiesUpdateParameters. internal partial class IntegrationFabricPropertiesUpdateParameters { - /// - /// 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 IntegrationFabricPropertiesUpdateParameters() @@ -53,11 +25,11 @@ public IntegrationFabricPropertiesUpdateParameters() /// Initializes a new instance of . /// The new integration scenarios covered by this integration fabric. - /// Keeps track of any properties unknown to the library. - internal IntegrationFabricPropertiesUpdateParameters(IList scenarios, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal IntegrationFabricPropertiesUpdateParameters(IList scenarios, IDictionary additionalBinaryDataProperties) { Scenarios = scenarios; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The new integration scenarios covered by this integration fabric. diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardListResponse.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardListResponse.Serialization.cs index 2cf36a7d6331..11fef5e4fa1d 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardListResponse.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardListResponse.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.Grafana; namespace Azure.ResourceManager.Grafana.Models { - internal partial class ManagedDashboardListResponse : IUtf8JsonSerializable, IJsonModel + /// Paged collection of ManagedDashboard items. + internal partial class ManagedDashboardListResponse : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ManagedDashboardListResponse() + { + } + /// 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, 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(ManagedDashboardListResponse)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (ManagedDashboardData 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 } } - ManagedDashboardListResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedDashboardListResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ManagedDashboardListResponse 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(ManagedDashboardListResponse)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedDashboardListResponse(document.RootElement, options); } - internal static ManagedDashboardListResponse DeserializeManagedDashboardListResponse(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedDashboardListResponse DeserializeManagedDashboardListResponse(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(ManagedDashboardData.DeserializeManagedDashboardData(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 ManagedDashboardListResponse(value, nextLink, serializedAdditionalRawData); + return new ManagedDashboardListResponse(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(ModelReaderWrit } } - ManagedDashboardListResponse 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. + ManagedDashboardListResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ManagedDashboardListResponse 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 DeserializeManagedDashboardListResponse(document.RootElement, options); } default: @@ -146,6 +163,14 @@ ManagedDashboardListResponse IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static ManagedDashboardListResponse FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeManagedDashboardListResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardListResponse.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardListResponse.cs index cd94a0671d96..a5468e682ab2 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardListResponse.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardListResponse.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// Paged collection of ManagedDashboard items. internal partial class ManagedDashboardListResponse { - /// - /// 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 ManagedDashboard items on this page. - /// is null. internal ManagedDashboardListResponse(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The ManagedDashboard items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal ManagedDashboardListResponse(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ManagedDashboardListResponse(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ManagedDashboardListResponse() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The ManagedDashboard 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardPatch.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardPatch.Serialization.cs index 75473a6802a6..1ed685c41878 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardPatch.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardPatch.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class ManagedDashboardPatch : IUtf8JsonSerializable, IJsonModel + /// The parameters for a PATCH request to a managed dashboard resource. + public partial class ManagedDashboardPatch : 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(ManagedDashboardPatch)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -41,19 +42,24 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Tags) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } - if (options.Format != "W" && _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 } } - ManagedDashboardPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedDashboardPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ManagedDashboardPatch 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(ManagedDashboardPatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedDashboardPatch(document.RootElement, options); } - internal static ManagedDashboardPatch DeserializeManagedDashboardPatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedDashboardPatch DeserializeManagedDashboardPatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IDictionary tags = 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("tags"u8)) + if (prop.NameEquals("tags"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()); + } } tags = 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 ManagedDashboardPatch(tags ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new ManagedDashboardPatch(tags ?? 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 } } - ManagedDashboardPatch 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. + ManagedDashboardPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ManagedDashboardPatch 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 DeserializeManagedDashboardPatch(document.RootElement, options); } default: @@ -139,6 +163,19 @@ ManagedDashboardPatch 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(ManagedDashboardPatch managedDashboardPatch) + { + if (managedDashboardPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(managedDashboardPatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardPatch.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardPatch.cs index 067b3a5fe32e..e71c98490cae 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardPatch.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardPatch.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// The parameters for a PATCH request to a managed dashboard resource. public partial class ManagedDashboardPatch { - /// - /// 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 ManagedDashboardPatch() @@ -53,11 +25,11 @@ public ManagedDashboardPatch() /// Initializes a new instance of . /// The new tags of the managed dashboard resource. - /// Keeps track of any properties unknown to the library. - internal ManagedDashboardPatch(IDictionary tags, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ManagedDashboardPatch(IDictionary tags, IDictionary additionalBinaryDataProperties) { Tags = tags; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The new tags of the managed dashboard resource. diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardProperties.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardProperties.Serialization.cs new file mode 100644 index 000000000000..a71bb2a78733 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardProperties.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.Grafana; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// Properties specific to the grafana resource. + internal partial class ManagedDashboardProperties : 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(ManagedDashboardProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ManagedDashboardProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ManagedDashboardProperties 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(ManagedDashboardProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedDashboardProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedDashboardProperties DeserializeManagedDashboardProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + GrafanaProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new GrafanaProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ManagedDashboardProperties(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, AzureResourceManagerGrafanaContext.Default); + default: + throw new FormatException($"The model {nameof(ManagedDashboardProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ManagedDashboardProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ManagedDashboardProperties 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 DeserializeManagedDashboardProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedDashboardProperties)} 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardProperties.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardProperties.cs new file mode 100644 index 000000000000..e9b23696b3b5 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedDashboardProperties.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// Properties specific to the grafana resource. + internal partial class ManagedDashboardProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ManagedDashboardProperties() + { + } + + /// Initializes a new instance of . + /// Provisioning state of the resource. + /// Keeps track of any properties unknown to the library. + internal ManagedDashboardProperties(GrafanaProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Provisioning state of the resource. + public GrafanaProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaListResponse.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaListResponse.Serialization.cs index eb6a03a0569f..5851298bf38c 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaListResponse.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaListResponse.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.Grafana; namespace Azure.ResourceManager.Grafana.Models { - internal partial class ManagedGrafanaListResponse : IUtf8JsonSerializable, IJsonModel + /// Paged collection of ManagedGrafana items. + internal partial class ManagedGrafanaListResponse : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ManagedGrafanaListResponse() + { + } + /// 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, 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(ManagedGrafanaListResponse)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (ManagedGrafanaData 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 } } - ManagedGrafanaListResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedGrafanaListResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ManagedGrafanaListResponse 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(ManagedGrafanaListResponse)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedGrafanaListResponse(document.RootElement, options); } - internal static ManagedGrafanaListResponse DeserializeManagedGrafanaListResponse(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedGrafanaListResponse DeserializeManagedGrafanaListResponse(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(ManagedGrafanaData.DeserializeManagedGrafanaData(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 ManagedGrafanaListResponse(value, nextLink, serializedAdditionalRawData); + return new ManagedGrafanaListResponse(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(ModelReaderWriter } } - ManagedGrafanaListResponse 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. + ManagedGrafanaListResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ManagedGrafanaListResponse 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 DeserializeManagedGrafanaListResponse(document.RootElement, options); } default: @@ -146,6 +163,14 @@ ManagedGrafanaListResponse IPersistableModel.Create( } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static ManagedGrafanaListResponse FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeManagedGrafanaListResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaListResponse.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaListResponse.cs index 8dc858955383..33fb4c35ad27 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaListResponse.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaListResponse.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// Paged collection of ManagedGrafana items. internal partial class ManagedGrafanaListResponse { - /// - /// 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 ManagedGrafana items on this page. - /// is null. internal ManagedGrafanaListResponse(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The ManagedGrafana items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal ManagedGrafanaListResponse(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ManagedGrafanaListResponse(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ManagedGrafanaListResponse() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The ManagedGrafana 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatch.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatch.Serialization.cs index 641b1d51be38..17c0d5a851b1 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatch.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatch.Serialization.cs @@ -11,14 +11,16 @@ using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Grafana; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.Grafana.Models { - public partial class ManagedGrafanaPatch : IUtf8JsonSerializable, IJsonModel + /// The parameters for a PATCH request to a grafana resource. + public partial class ManagedGrafanaPatch : 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,12 +32,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(ManagedGrafanaPatch)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Sku)) { writer.WritePropertyName("sku"u8); @@ -44,7 +45,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireV3Options); + ((IJsonModel)Identity).Write(writer, options); } if (Optional.IsCollectionDefined(Tags)) { @@ -53,6 +54,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Tags) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); @@ -62,15 +68,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties, 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); } @@ -79,22 +85,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ManagedGrafanaPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedGrafanaPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ManagedGrafanaPatch 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(ManagedGrafanaPatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedGrafanaPatch(document.RootElement, options); } - internal static ManagedGrafanaPatch DeserializeManagedGrafanaPatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedGrafanaPatch DeserializeManagedGrafanaPatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -103,64 +114,72 @@ internal static ManagedGrafanaPatch DeserializeManagedGrafanaPatch(JsonElement e ManagedServiceIdentity identity = default; IDictionary tags = default; ManagedGrafanaPatchProperties properties = 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("sku"u8)) + if (prop.NameEquals("sku"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - sku = ManagedGrafanaSku.DeserializeManagedGrafanaSku(property.Value, options); + sku = ManagedGrafanaSku.DeserializeManagedGrafanaSku(prop.Value, options); continue; } - if (property.NameEquals("identity"u8)) + if (prop.NameEquals("identity"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireV3Options, AzureResourceManagerGrafanaContext.Default); + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerGrafanaContext.Default); continue; } - if (property.NameEquals("tags"u8)) + if (prop.NameEquals("tags"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()); + } } tags = dictionary; continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = ManagedGrafanaPatchProperties.DeserializeManagedGrafanaPatchProperties(property.Value, options); + properties = ManagedGrafanaPatchProperties.DeserializeManagedGrafanaPatchProperties(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 ManagedGrafanaPatch(sku, identity, tags ?? new ChangeTrackingDictionary(), properties, serializedAdditionalRawData); + return new ManagedGrafanaPatch(sku, identity, tags ?? new ChangeTrackingDictionary(), 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": @@ -170,15 +189,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - ManagedGrafanaPatch 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. + ManagedGrafanaPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ManagedGrafanaPatch 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 DeserializeManagedGrafanaPatch(document.RootElement, options); } default: @@ -186,6 +210,19 @@ ManagedGrafanaPatch 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(ManagedGrafanaPatch managedGrafanaPatch) + { + if (managedGrafanaPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(managedGrafanaPatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatch.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatch.cs index 6754f2f68439..790473f12288 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatch.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatch.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.Grafana; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.Grafana.Models @@ -14,37 +15,8 @@ namespace Azure.ResourceManager.Grafana.Models /// The parameters for a PATCH request to a grafana resource. public partial class ManagedGrafanaPatch { - /// - /// 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 ManagedGrafanaPatch() @@ -57,22 +29,25 @@ public ManagedGrafanaPatch() /// The managed identity of the grafana resource. /// The new tags of the grafana resource. /// Properties specific to the managed grafana resource. - /// Keeps track of any properties unknown to the library. - internal ManagedGrafanaPatch(ManagedGrafanaSku sku, ManagedServiceIdentity identity, IDictionary tags, ManagedGrafanaPatchProperties properties, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ManagedGrafanaPatch(ManagedGrafanaSku sku, ManagedServiceIdentity identity, IDictionary tags, ManagedGrafanaPatchProperties properties, IDictionary additionalBinaryDataProperties) { Sku = sku; Identity = identity; Tags = tags; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } - /// Gets or sets the sku. + /// Gets or sets the Sku. public ManagedGrafanaSku Sku { get; set; } + /// The managed identity of the grafana resource. public ManagedServiceIdentity Identity { get; set; } + /// The new tags of the grafana resource. public IDictionary Tags { get; } + /// Properties specific to the managed grafana resource. public ManagedGrafanaPatchProperties Properties { get; set; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatchProperties.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatchProperties.Serialization.cs index a21b21f5e88a..6b879ef0ba74 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatchProperties.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatchProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class ManagedGrafanaPatchProperties : IUtf8JsonSerializable, IJsonModel + /// The properties parameters for a PATCH request to a grafana resource. + public partial class ManagedGrafanaPatchProperties : 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, 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(ManagedGrafanaPatchProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ZoneRedundancy)) { writer.WritePropertyName("zoneRedundancy"u8); @@ -90,15 +90,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("grafanaMajorVersion"u8); writer.WriteStringValue(GrafanaMajorVersion); } - 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); } @@ -107,22 +107,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ManagedGrafanaPatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedGrafanaPatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ManagedGrafanaPatchProperties 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(ManagedGrafanaPatchProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedGrafanaPatchProperties(document.RootElement, options); } - internal static ManagedGrafanaPatchProperties DeserializeManagedGrafanaPatchProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedGrafanaPatchProperties DeserializeManagedGrafanaPatchProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -137,107 +142,105 @@ internal static ManagedGrafanaPatchProperties DeserializeManagedGrafanaPatchProp GrafanaConfigurations grafanaConfigurations = default; IDictionary grafanaPlugins = default; string grafanaMajorVersion = 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("zoneRedundancy"u8)) + if (prop.NameEquals("zoneRedundancy"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - zoneRedundancy = new GrafanaZoneRedundancy(property.Value.GetString()); + zoneRedundancy = new GrafanaZoneRedundancy(prop.Value.GetString()); continue; } - if (property.NameEquals("apiKey"u8)) + if (prop.NameEquals("apiKey"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - apiKey = new GrafanaApiKey(property.Value.GetString()); + apiKey = new GrafanaApiKey(prop.Value.GetString()); continue; } - if (property.NameEquals("creatorCanAdmin"u8)) + if (prop.NameEquals("creatorCanAdmin"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - creatorCanAdmin = new GrafanaCreatorCanAdmin(property.Value.GetString()); + creatorCanAdmin = new GrafanaCreatorCanAdmin(prop.Value.GetString()); continue; } - if (property.NameEquals("deterministicOutboundIP"u8)) + if (prop.NameEquals("deterministicOutboundIP"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deterministicOutboundIP = new DeterministicOutboundIP(property.Value.GetString()); + deterministicOutboundIP = new DeterministicOutboundIP(prop.Value.GetString()); continue; } - if (property.NameEquals("publicNetworkAccess"u8)) + if (prop.NameEquals("publicNetworkAccess"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - publicNetworkAccess = new GrafanaPublicNetworkAccess(property.Value.GetString()); + publicNetworkAccess = new GrafanaPublicNetworkAccess(prop.Value.GetString()); continue; } - if (property.NameEquals("grafanaIntegrations"u8)) + if (prop.NameEquals("grafanaIntegrations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - grafanaIntegrations = GrafanaIntegrations.DeserializeGrafanaIntegrations(property.Value, options); + grafanaIntegrations = GrafanaIntegrations.DeserializeGrafanaIntegrations(prop.Value, options); continue; } - if (property.NameEquals("enterpriseConfigurations"u8)) + if (prop.NameEquals("enterpriseConfigurations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - enterpriseConfigurations = EnterpriseConfigurations.DeserializeEnterpriseConfigurations(property.Value, options); + enterpriseConfigurations = EnterpriseConfigurations.DeserializeEnterpriseConfigurations(prop.Value, options); continue; } - if (property.NameEquals("grafanaConfigurations"u8)) + if (prop.NameEquals("grafanaConfigurations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - grafanaConfigurations = GrafanaConfigurations.DeserializeGrafanaConfigurations(property.Value, options); + grafanaConfigurations = GrafanaConfigurations.DeserializeGrafanaConfigurations(prop.Value, options); continue; } - if (property.NameEquals("grafanaPlugins"u8)) + if (prop.NameEquals("grafanaPlugins"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, GrafanaPlugin.DeserializeGrafanaPlugin(property0.Value, options)); + dictionary.Add(prop0.Name, GrafanaPlugin.DeserializeGrafanaPlugin(prop0.Value, options)); } grafanaPlugins = dictionary; continue; } - if (property.NameEquals("grafanaMajorVersion"u8)) + if (prop.NameEquals("grafanaMajorVersion"u8)) { - grafanaMajorVersion = property.Value.GetString(); + grafanaMajorVersion = 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 ManagedGrafanaPatchProperties( zoneRedundancy, apiKey, @@ -249,13 +252,16 @@ internal static ManagedGrafanaPatchProperties DeserializeManagedGrafanaPatchProp grafanaConfigurations, grafanaPlugins ?? new ChangeTrackingDictionary(), grafanaMajorVersion, - 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": @@ -265,15 +271,20 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - ManagedGrafanaPatchProperties 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. + ManagedGrafanaPatchProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ManagedGrafanaPatchProperties 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 DeserializeManagedGrafanaPatchProperties(document.RootElement, options); } default: @@ -281,6 +292,7 @@ ManagedGrafanaPatchProperties IPersistableModel.C } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatchProperties.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatchProperties.cs index 2015c8ba812f..4ead745fcd13 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatchProperties.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaPatchProperties.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// The properties parameters for a PATCH request to a grafana resource. public partial class ManagedGrafanaPatchProperties { - /// - /// 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 ManagedGrafanaPatchProperties() @@ -62,8 +34,8 @@ public ManagedGrafanaPatchProperties() /// Server configurations of a Grafana instance. /// Update of Grafana plugin. Key is plugin id, value is plugin definition. If plugin definition is null, plugin with given plugin id will be removed. Otherwise, given plugin will be installed. /// The major Grafana software version to target. - /// Keeps track of any properties unknown to the library. - internal ManagedGrafanaPatchProperties(GrafanaZoneRedundancy? zoneRedundancy, GrafanaApiKey? apiKey, GrafanaCreatorCanAdmin? creatorCanAdmin, DeterministicOutboundIP? deterministicOutboundIP, GrafanaPublicNetworkAccess? publicNetworkAccess, GrafanaIntegrations grafanaIntegrations, EnterpriseConfigurations enterpriseConfigurations, GrafanaConfigurations grafanaConfigurations, IDictionary grafanaPlugins, string grafanaMajorVersion, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ManagedGrafanaPatchProperties(GrafanaZoneRedundancy? zoneRedundancy, GrafanaApiKey? apiKey, GrafanaCreatorCanAdmin? creatorCanAdmin, DeterministicOutboundIP? deterministicOutboundIP, GrafanaPublicNetworkAccess? publicNetworkAccess, GrafanaIntegrations grafanaIntegrations, EnterpriseConfigurations enterpriseConfigurations, GrafanaConfigurations grafanaConfigurations, IDictionary grafanaPlugins, string grafanaMajorVersion, IDictionary additionalBinaryDataProperties) { ZoneRedundancy = zoneRedundancy; ApiKey = apiKey; @@ -75,39 +47,50 @@ internal ManagedGrafanaPatchProperties(GrafanaZoneRedundancy? zoneRedundancy, Gr GrafanaConfigurations = grafanaConfigurations; GrafanaPlugins = grafanaPlugins; GrafanaMajorVersion = grafanaMajorVersion; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The zone redundancy setting of the Grafana instance. public GrafanaZoneRedundancy? ZoneRedundancy { get; set; } + /// The api key setting of the Grafana instance. public GrafanaApiKey? ApiKey { get; set; } + /// The creator will have admin access for the Grafana instance. public GrafanaCreatorCanAdmin? CreatorCanAdmin { get; set; } + /// Whether a Grafana instance uses deterministic outbound IPs. public DeterministicOutboundIP? DeterministicOutboundIP { get; set; } + /// Indicate the state for enable or disable traffic over the public interface. public GrafanaPublicNetworkAccess? PublicNetworkAccess { get; set; } + /// GrafanaIntegrations is a bundled observability experience (e.g. pre-configured data source, tailored Grafana dashboards, alerting defaults) for common monitoring scenarios. internal GrafanaIntegrations GrafanaIntegrations { get; set; } - /// Gets the monitor workspace integrations. - public IList MonitorWorkspaceIntegrations - { - get - { - if (GrafanaIntegrations is null) - GrafanaIntegrations = new GrafanaIntegrations(); - return GrafanaIntegrations.MonitorWorkspaceIntegrations; - } - } /// Enterprise settings of a Grafana instance. public EnterpriseConfigurations EnterpriseConfigurations { get; set; } + /// Server configurations of a Grafana instance. public GrafanaConfigurations GrafanaConfigurations { get; set; } + /// Update of Grafana plugin. Key is plugin id, value is plugin definition. If plugin definition is null, plugin with given plugin id will be removed. Otherwise, given plugin will be installed. public IDictionary GrafanaPlugins { get; } + /// The major Grafana software version to target. public string GrafanaMajorVersion { get; set; } + + /// Gets the MonitorWorkspaceIntegrations. + public IList MonitorWorkspaceIntegrations + { + get + { + if (GrafanaIntegrations is null) + { + GrafanaIntegrations = new GrafanaIntegrations(); + } + return GrafanaIntegrations.MonitorWorkspaceIntegrations; + } + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaProperties.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaProperties.Serialization.cs index 4fd19c743d7c..444f569e6dbc 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaProperties.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class ManagedGrafanaProperties : IUtf8JsonSerializable, IJsonModel + /// Properties specific to the grafana resource. + public partial class ManagedGrafanaProperties : 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(ManagedGrafanaProperties)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) { writer.WritePropertyName("provisioningState"u8); @@ -78,8 +78,13 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("outboundIPs"u8); writer.WriteStartArray(); - foreach (var item in OutboundIPs) + foreach (string item in OutboundIPs) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -88,7 +93,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("privateEndpointConnections"u8); writer.WriteStartArray(); - foreach (var item in PrivateEndpointConnections) + foreach (GrafanaPrivateEndpointConnectionData item in PrivateEndpointConnections) { writer.WriteObjectValue(item, options); } @@ -130,15 +135,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("grafanaMajorVersion"u8); writer.WriteStringValue(GrafanaMajorVersion); } - 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); } @@ -147,22 +152,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ManagedGrafanaProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedGrafanaProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ManagedGrafanaProperties 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(ManagedGrafanaProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedGrafanaProperties(document.RootElement, options); } - internal static ManagedGrafanaProperties DeserializeManagedGrafanaProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedGrafanaProperties DeserializeManagedGrafanaProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -183,163 +193,168 @@ internal static ManagedGrafanaProperties DeserializeManagedGrafanaProperties(Jso GrafanaConfigurations grafanaConfigurations = default; IDictionary grafanaPlugins = default; string grafanaMajorVersion = 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("provisioningState"u8)) + if (prop.NameEquals("provisioningState"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - provisioningState = new GrafanaProvisioningState(property.Value.GetString()); + provisioningState = new GrafanaProvisioningState(prop.Value.GetString()); continue; } - if (property.NameEquals("grafanaVersion"u8)) + if (prop.NameEquals("grafanaVersion"u8)) { - grafanaVersion = property.Value.GetString(); + grafanaVersion = prop.Value.GetString(); continue; } - if (property.NameEquals("endpoint"u8)) + if (prop.NameEquals("endpoint"u8)) { - endpoint = property.Value.GetString(); + endpoint = prop.Value.GetString(); continue; } - if (property.NameEquals("publicNetworkAccess"u8)) + if (prop.NameEquals("publicNetworkAccess"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - publicNetworkAccess = new GrafanaPublicNetworkAccess(property.Value.GetString()); + publicNetworkAccess = new GrafanaPublicNetworkAccess(prop.Value.GetString()); continue; } - if (property.NameEquals("zoneRedundancy"u8)) + if (prop.NameEquals("zoneRedundancy"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - zoneRedundancy = new GrafanaZoneRedundancy(property.Value.GetString()); + zoneRedundancy = new GrafanaZoneRedundancy(prop.Value.GetString()); continue; } - if (property.NameEquals("apiKey"u8)) + if (prop.NameEquals("apiKey"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - apiKey = new GrafanaApiKey(property.Value.GetString()); + apiKey = new GrafanaApiKey(prop.Value.GetString()); continue; } - if (property.NameEquals("creatorCanAdmin"u8)) + if (prop.NameEquals("creatorCanAdmin"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - creatorCanAdmin = new GrafanaCreatorCanAdmin(property.Value.GetString()); + creatorCanAdmin = new GrafanaCreatorCanAdmin(prop.Value.GetString()); continue; } - if (property.NameEquals("deterministicOutboundIP"u8)) + if (prop.NameEquals("deterministicOutboundIP"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deterministicOutboundIP = new DeterministicOutboundIP(property.Value.GetString()); + deterministicOutboundIP = new DeterministicOutboundIP(prop.Value.GetString()); continue; } - if (property.NameEquals("outboundIPs"u8)) + if (prop.NameEquals("outboundIPs"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()); + } } outboundIPs = array; continue; } - if (property.NameEquals("privateEndpointConnections"u8)) + if (prop.NameEquals("privateEndpointConnections"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(GrafanaPrivateEndpointConnectionData.DeserializeGrafanaPrivateEndpointConnectionData(item, options)); } privateEndpointConnections = array; continue; } - if (property.NameEquals("autoGeneratedDomainNameLabelScope"u8)) + if (prop.NameEquals("autoGeneratedDomainNameLabelScope"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - autoGeneratedDomainNameLabelScope = new AutoGeneratedDomainNameLabelScope(property.Value.GetString()); + autoGeneratedDomainNameLabelScope = new AutoGeneratedDomainNameLabelScope(prop.Value.GetString()); continue; } - if (property.NameEquals("grafanaIntegrations"u8)) + if (prop.NameEquals("grafanaIntegrations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - grafanaIntegrations = GrafanaIntegrations.DeserializeGrafanaIntegrations(property.Value, options); + grafanaIntegrations = GrafanaIntegrations.DeserializeGrafanaIntegrations(prop.Value, options); continue; } - if (property.NameEquals("enterpriseConfigurations"u8)) + if (prop.NameEquals("enterpriseConfigurations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - enterpriseConfigurations = EnterpriseConfigurations.DeserializeEnterpriseConfigurations(property.Value, options); + enterpriseConfigurations = EnterpriseConfigurations.DeserializeEnterpriseConfigurations(prop.Value, options); continue; } - if (property.NameEquals("grafanaConfigurations"u8)) + if (prop.NameEquals("grafanaConfigurations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - grafanaConfigurations = GrafanaConfigurations.DeserializeGrafanaConfigurations(property.Value, options); + grafanaConfigurations = GrafanaConfigurations.DeserializeGrafanaConfigurations(prop.Value, options); continue; } - if (property.NameEquals("grafanaPlugins"u8)) + if (prop.NameEquals("grafanaPlugins"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, GrafanaPlugin.DeserializeGrafanaPlugin(property0.Value, options)); + dictionary.Add(prop0.Name, GrafanaPlugin.DeserializeGrafanaPlugin(prop0.Value, options)); } grafanaPlugins = dictionary; continue; } - if (property.NameEquals("grafanaMajorVersion"u8)) + if (prop.NameEquals("grafanaMajorVersion"u8)) { - grafanaMajorVersion = property.Value.GetString(); + grafanaMajorVersion = 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 ManagedGrafanaProperties( provisioningState, grafanaVersion, @@ -357,13 +372,16 @@ internal static ManagedGrafanaProperties DeserializeManagedGrafanaProperties(Jso grafanaConfigurations, grafanaPlugins ?? new ChangeTrackingDictionary(), grafanaMajorVersion, - 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": @@ -373,15 +391,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp } } - ManagedGrafanaProperties 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. + ManagedGrafanaProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ManagedGrafanaProperties 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 DeserializeManagedGrafanaProperties(document.RootElement, options); } default: @@ -389,6 +412,7 @@ ManagedGrafanaProperties IPersistableModel.Create(Bina } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaProperties.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaProperties.cs index 032922c69909..52ab822c5874 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaProperties.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaProperties.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// Properties specific to the grafana resource. public partial class ManagedGrafanaProperties { - /// - /// 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 ManagedGrafanaProperties() @@ -70,8 +42,8 @@ public ManagedGrafanaProperties() /// Server configurations of a Grafana instance. /// Installed plugin list of the Grafana instance. Key is plugin id, value is plugin definition. /// The major Grafana software version to target. - /// Keeps track of any properties unknown to the library. - internal ManagedGrafanaProperties(GrafanaProvisioningState? provisioningState, string grafanaVersion, string endpoint, GrafanaPublicNetworkAccess? publicNetworkAccess, GrafanaZoneRedundancy? zoneRedundancy, GrafanaApiKey? apiKey, GrafanaCreatorCanAdmin? creatorCanAdmin, DeterministicOutboundIP? deterministicOutboundIP, IReadOnlyList outboundIPs, IReadOnlyList privateEndpointConnections, AutoGeneratedDomainNameLabelScope? autoGeneratedDomainNameLabelScope, GrafanaIntegrations grafanaIntegrations, EnterpriseConfigurations enterpriseConfigurations, GrafanaConfigurations grafanaConfigurations, IDictionary grafanaPlugins, string grafanaMajorVersion, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ManagedGrafanaProperties(GrafanaProvisioningState? provisioningState, string grafanaVersion, string endpoint, GrafanaPublicNetworkAccess? publicNetworkAccess, GrafanaZoneRedundancy? zoneRedundancy, GrafanaApiKey? apiKey, GrafanaCreatorCanAdmin? creatorCanAdmin, DeterministicOutboundIP? deterministicOutboundIP, IReadOnlyList outboundIPs, IReadOnlyList privateEndpointConnections, AutoGeneratedDomainNameLabelScope? autoGeneratedDomainNameLabelScope, GrafanaIntegrations grafanaIntegrations, EnterpriseConfigurations enterpriseConfigurations, GrafanaConfigurations grafanaConfigurations, IDictionary grafanaPlugins, string grafanaMajorVersion, IDictionary additionalBinaryDataProperties) { ProvisioningState = provisioningState; GrafanaVersion = grafanaVersion; @@ -89,51 +61,68 @@ internal ManagedGrafanaProperties(GrafanaProvisioningState? provisioningState, s GrafanaConfigurations = grafanaConfigurations; GrafanaPlugins = grafanaPlugins; GrafanaMajorVersion = grafanaMajorVersion; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Provisioning state of the resource. public GrafanaProvisioningState? ProvisioningState { get; } + /// The Grafana software version. public string GrafanaVersion { get; } + /// The endpoint of the Grafana instance. public string Endpoint { get; } + /// Indicate the state for enable or disable traffic over the public interface. public GrafanaPublicNetworkAccess? PublicNetworkAccess { get; set; } + /// The zone redundancy setting of the Grafana instance. public GrafanaZoneRedundancy? ZoneRedundancy { get; set; } + /// The api key setting of the Grafana instance. public GrafanaApiKey? ApiKey { get; set; } + /// The creator will have admin access for the Grafana instance. public GrafanaCreatorCanAdmin? CreatorCanAdmin { get; set; } + /// Whether a Grafana instance uses deterministic outbound IPs. public DeterministicOutboundIP? DeterministicOutboundIP { get; set; } + /// List of outbound IPs if deterministicOutboundIP is enabled. public IReadOnlyList OutboundIPs { get; } + /// The private endpoint connections of the Grafana instance. public IReadOnlyList PrivateEndpointConnections { get; } + /// Scope for dns deterministic name hash calculation. public AutoGeneratedDomainNameLabelScope? AutoGeneratedDomainNameLabelScope { get; set; } + /// GrafanaIntegrations is a bundled observability experience (e.g. pre-configured data source, tailored Grafana dashboards, alerting defaults) for common monitoring scenarios. internal GrafanaIntegrations GrafanaIntegrations { get; set; } - /// Gets the monitor workspace integrations. - public IList MonitorWorkspaceIntegrations - { - get - { - if (GrafanaIntegrations is null) - GrafanaIntegrations = new GrafanaIntegrations(); - return GrafanaIntegrations.MonitorWorkspaceIntegrations; - } - } /// Enterprise settings of a Grafana instance. public EnterpriseConfigurations EnterpriseConfigurations { get; set; } + /// Server configurations of a Grafana instance. public GrafanaConfigurations GrafanaConfigurations { get; set; } + /// Installed plugin list of the Grafana instance. Key is plugin id, value is plugin definition. public IDictionary GrafanaPlugins { get; } + /// The major Grafana software version to target. public string GrafanaMajorVersion { get; set; } + + /// Gets the MonitorWorkspaceIntegrations. + public IList MonitorWorkspaceIntegrations + { + get + { + if (GrafanaIntegrations is null) + { + GrafanaIntegrations = new GrafanaIntegrations(); + } + return GrafanaIntegrations.MonitorWorkspaceIntegrations; + } + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaSku.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaSku.Serialization.cs index 13cfc096c820..cff7cc1ba4be 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaSku.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaSku.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class ManagedGrafanaSku : IUtf8JsonSerializable, IJsonModel + /// Represents the SKU of a resource. + public partial class ManagedGrafanaSku : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ManagedGrafanaSku() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +34,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(ManagedGrafanaSku)} does not support writing '{format}' format."); } - writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); if (Optional.IsDefined(Size)) @@ -41,15 +46,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("size"u8); writer.WriteStringValue(Size.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); } @@ -58,59 +63,65 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ManagedGrafanaSku IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedGrafanaSku IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ManagedGrafanaSku 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(ManagedGrafanaSku)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedGrafanaSku(document.RootElement, options); } - internal static ManagedGrafanaSku DeserializeManagedGrafanaSku(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedGrafanaSku DeserializeManagedGrafanaSku(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; GrafanaSize? size = 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("size"u8)) + if (prop.NameEquals("size"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - size = new GrafanaSize(property.Value.GetString()); + size = new GrafanaSize(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 ManagedGrafanaSku(name, size, serializedAdditionalRawData); + return new ManagedGrafanaSku(name, size, 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": @@ -120,15 +131,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - ManagedGrafanaSku 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. + ManagedGrafanaSku IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ManagedGrafanaSku 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 DeserializeManagedGrafanaSku(document.RootElement, options); } default: @@ -136,6 +152,7 @@ ManagedGrafanaSku IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaSku.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaSku.cs index 5d44b45b8471..044e2f2d1b26 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaSku.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedGrafanaSku.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// Represents the SKU of a resource. public partial class ManagedGrafanaSku { - /// - /// 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 name of the SKU. @@ -58,21 +30,17 @@ public ManagedGrafanaSku(string name) /// Initializes a new instance of . /// The name of the SKU. /// Specifies the capacity tier of the Grafana instance. - /// Keeps track of any properties unknown to the library. - internal ManagedGrafanaSku(string name, GrafanaSize? size, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ManagedGrafanaSku(string name, GrafanaSize? size, IDictionary additionalBinaryDataProperties) { Name = name; Size = size; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ManagedGrafanaSku() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The name of the SKU. public string Name { get; set; } + /// Specifies the capacity tier of the Grafana instance. public GrafanaSize? Size { get; set; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointConnectionState.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointConnectionState.Serialization.cs index 5f6475eb8f71..d1fa6e7a4429 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointConnectionState.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointConnectionState.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class ManagedPrivateEndpointConnectionState : IUtf8JsonSerializable, IJsonModel + /// The state of managed private endpoint connection. + public partial class ManagedPrivateEndpointConnectionState : 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 writ /// 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(ManagedPrivateEndpointConnectionState)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(Status)) { writer.WritePropertyName("status"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("description"u8); writer.WriteStringValue(Description); } - 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 } } - ManagedPrivateEndpointConnectionState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedPrivateEndpointConnectionState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ManagedPrivateEndpointConnectionState 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(ManagedPrivateEndpointConnectionState)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedPrivateEndpointConnectionState(document.RootElement, options); } - internal static ManagedPrivateEndpointConnectionState DeserializeManagedPrivateEndpointConnectionState(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedPrivateEndpointConnectionState DeserializeManagedPrivateEndpointConnectionState(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ManagedPrivateEndpointConnectionStatus? status = default; string description = 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("status"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - status = new ManagedPrivateEndpointConnectionStatus(property.Value.GetString()); + status = new ManagedPrivateEndpointConnectionStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = 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 ManagedPrivateEndpointConnectionState(status, description, serializedAdditionalRawData); + return new ManagedPrivateEndpointConnectionState(status, description, 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(ModelR } } - ManagedPrivateEndpointConnectionState 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. + ManagedPrivateEndpointConnectionState IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ManagedPrivateEndpointConnectionState 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 DeserializeManagedPrivateEndpointConnectionState(document.RootElement, options); } default: @@ -139,6 +150,7 @@ ManagedPrivateEndpointConnectionState IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointConnectionState.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointConnectionState.cs index 7f9898395a64..465f547601c1 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointConnectionState.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointConnectionState.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.Grafana.Models /// The state of managed private endpoint connection. public partial class ManagedPrivateEndpointConnectionState { - /// - /// 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 ManagedPrivateEndpointConnectionState() @@ -53,16 +24,17 @@ internal ManagedPrivateEndpointConnectionState() /// Initializes a new instance of . /// The approval/rejection status of managed private endpoint connection. /// Gets or sets the reason for approval/rejection of the connection. - /// Keeps track of any properties unknown to the library. - internal ManagedPrivateEndpointConnectionState(ManagedPrivateEndpointConnectionStatus? status, string description, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ManagedPrivateEndpointConnectionState(ManagedPrivateEndpointConnectionStatus? status, string description, IDictionary additionalBinaryDataProperties) { Status = status; Description = description; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The approval/rejection status of managed private endpoint connection. public ManagedPrivateEndpointConnectionStatus? Status { get; } + /// Gets or sets the reason for approval/rejection of the connection. public string Description { get; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointConnectionStatus.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointConnectionStatus.cs index bf1cc2aabad3..c096dfb7c916 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointConnectionStatus.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointConnectionStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { @@ -14,44 +15,63 @@ namespace Azure.ResourceManager.Grafana.Models public readonly partial struct ManagedPrivateEndpointConnectionStatus : IEquatable { private readonly string _value; + private const string PendingValue = "Pending"; + private const string ApprovedValue = "Approved"; + private const string RejectedValue = "Rejected"; + private const string DisconnectedValue = "Disconnected"; /// Initializes a new instance of . + /// The value. /// is null. public ManagedPrivateEndpointConnectionStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string PendingValue = "Pending"; - private const string ApprovedValue = "Approved"; - private const string RejectedValue = "Rejected"; - private const string DisconnectedValue = "Disconnected"; + _value = value; + } - /// Pending. + /// Gets the Pending. public static ManagedPrivateEndpointConnectionStatus Pending { get; } = new ManagedPrivateEndpointConnectionStatus(PendingValue); - /// Approved. + + /// Gets the Approved. public static ManagedPrivateEndpointConnectionStatus Approved { get; } = new ManagedPrivateEndpointConnectionStatus(ApprovedValue); - /// Rejected. + + /// Gets the Rejected. public static ManagedPrivateEndpointConnectionStatus Rejected { get; } = new ManagedPrivateEndpointConnectionStatus(RejectedValue); - /// Disconnected. + + /// Gets the Disconnected. public static ManagedPrivateEndpointConnectionStatus Disconnected { get; } = new ManagedPrivateEndpointConnectionStatus(DisconnectedValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(ManagedPrivateEndpointConnectionStatus left, ManagedPrivateEndpointConnectionStatus 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 !=(ManagedPrivateEndpointConnectionStatus left, ManagedPrivateEndpointConnectionStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator ManagedPrivateEndpointConnectionStatus(string value) => new ManagedPrivateEndpointConnectionStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator ManagedPrivateEndpointConnectionStatus?(string value) => value == null ? null : new ManagedPrivateEndpointConnectionStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is ManagedPrivateEndpointConnectionStatus other && Equals(other); - /// + + /// public bool Equals(ManagedPrivateEndpointConnectionStatus 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelListResponse.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelListResponse.Serialization.cs index fd79aa7f4369..9f383b9576d0 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelListResponse.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelListResponse.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.Grafana; namespace Azure.ResourceManager.Grafana.Models { - internal partial class ManagedPrivateEndpointModelListResponse : IUtf8JsonSerializable, IJsonModel + /// The list of managed private endpoints of a grafana resource. + internal partial class ManagedPrivateEndpointModelListResponse : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ManagedPrivateEndpointModelListResponse() + { + } + /// 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 wr /// 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(ManagedPrivateEndpointModelListResponse)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (ManagedPrivateEndpointModelData 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 } } - ManagedPrivateEndpointModelListResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedPrivateEndpointModelListResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ManagedPrivateEndpointModelListResponse 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(ManagedPrivateEndpointModelListResponse)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedPrivateEndpointModelListResponse(document.RootElement, options); } - internal static ManagedPrivateEndpointModelListResponse DeserializeManagedPrivateEndpointModelListResponse(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedPrivateEndpointModelListResponse DeserializeManagedPrivateEndpointModelListResponse(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(ManagedPrivateEndpointModelData.DeserializeManagedPrivateEndpointModelData(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 ManagedPrivateEndpointModelListResponse(value, nextLink, serializedAdditionalRawData); + return new ManagedPrivateEndpointModelListResponse(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(Mode } } - ManagedPrivateEndpointModelListResponse 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. + ManagedPrivateEndpointModelListResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ManagedPrivateEndpointModelListResponse 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 DeserializeManagedPrivateEndpointModelListResponse(document.RootElement, options); } default: @@ -146,6 +163,14 @@ ManagedPrivateEndpointModelListResponse IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static ManagedPrivateEndpointModelListResponse FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeManagedPrivateEndpointModelListResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelListResponse.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelListResponse.cs index 6e220c96362b..88582f87b54a 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelListResponse.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelListResponse.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// The list of managed private endpoints of a grafana resource. internal partial class ManagedPrivateEndpointModelListResponse { - /// - /// 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 ManagedPrivateEndpointModel items on this page. - /// is null. internal ManagedPrivateEndpointModelListResponse(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The ManagedPrivateEndpointModel items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal ManagedPrivateEndpointModelListResponse(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ManagedPrivateEndpointModelListResponse(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ManagedPrivateEndpointModelListResponse() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The ManagedPrivateEndpointModel 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelPatch.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelPatch.Serialization.cs index a35fa97b0d48..c2d297a48e4b 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelPatch.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelPatch.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class ManagedPrivateEndpointModelPatch : IUtf8JsonSerializable, IJsonModel + /// The parameters for a PATCH request to a managed private endpoint. + public partial class ManagedPrivateEndpointModelPatch : 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, M /// 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(ManagedPrivateEndpointModelPatch)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -41,19 +42,24 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Tags) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } - if (options.Format != "W" && _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 } } - ManagedPrivateEndpointModelPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedPrivateEndpointModelPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ManagedPrivateEndpointModelPatch 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(ManagedPrivateEndpointModelPatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedPrivateEndpointModelPatch(document.RootElement, options); } - internal static ManagedPrivateEndpointModelPatch DeserializeManagedPrivateEndpointModelPatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedPrivateEndpointModelPatch DeserializeManagedPrivateEndpointModelPatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IDictionary tags = 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("tags"u8)) + if (prop.NameEquals("tags"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()); + } } tags = 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 ManagedPrivateEndpointModelPatch(tags ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new ManagedPrivateEndpointModelPatch(tags ?? 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(ModelReader } } - ManagedPrivateEndpointModelPatch 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. + ManagedPrivateEndpointModelPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ManagedPrivateEndpointModelPatch 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 DeserializeManagedPrivateEndpointModelPatch(document.RootElement, options); } default: @@ -139,6 +163,19 @@ ManagedPrivateEndpointModelPatch IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ManagedPrivateEndpointModelPatch managedPrivateEndpointModelPatch) + { + if (managedPrivateEndpointModelPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(managedPrivateEndpointModelPatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelPatch.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelPatch.cs index 3b2f3cd37c9e..52573b3b1115 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelPatch.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelPatch.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { /// The parameters for a PATCH request to a managed private endpoint. public partial class ManagedPrivateEndpointModelPatch { - /// - /// 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 ManagedPrivateEndpointModelPatch() @@ -53,11 +25,11 @@ public ManagedPrivateEndpointModelPatch() /// Initializes a new instance of . /// The new tags of the managed private endpoint. - /// Keeps track of any properties unknown to the library. - internal ManagedPrivateEndpointModelPatch(IDictionary tags, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ManagedPrivateEndpointModelPatch(IDictionary tags, IDictionary additionalBinaryDataProperties) { Tags = tags; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The new tags of the managed private endpoint. diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelProperties.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelProperties.Serialization.cs new file mode 100644 index 000000000000..eb288255e09c --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelProperties.Serialization.cs @@ -0,0 +1,270 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Grafana; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// Properties specific to the managed private endpoint. + internal partial class ManagedPrivateEndpointModelProperties : 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(ManagedPrivateEndpointModelProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(PrivateLinkResourceId)) + { + writer.WritePropertyName("privateLinkResourceId"u8); + writer.WriteStringValue(PrivateLinkResourceId); + } + if (Optional.IsDefined(PrivateLinkResourceRegion)) + { + writer.WritePropertyName("privateLinkResourceRegion"u8); + writer.WriteStringValue(PrivateLinkResourceRegion); + } + if (Optional.IsCollectionDefined(GroupIds)) + { + writer.WritePropertyName("groupIds"u8); + writer.WriteStartArray(); + foreach (string item in GroupIds) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(RequestMessage)) + { + writer.WritePropertyName("requestMessage"u8); + writer.WriteStringValue(RequestMessage); + } + if (options.Format != "W" && Optional.IsDefined(ConnectionState)) + { + writer.WritePropertyName("connectionState"u8); + writer.WriteObjectValue(ConnectionState, options); + } + if (Optional.IsDefined(PrivateLinkServiceUri)) + { + writer.WritePropertyName("privateLinkServiceUrl"u8); + writer.WriteStringValue(PrivateLinkServiceUri.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(PrivateLinkServicePrivateIP)) + { + writer.WritePropertyName("privateLinkServicePrivateIP"u8); + writer.WriteStringValue(PrivateLinkServicePrivateIP); + } + 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. + ManagedPrivateEndpointModelProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ManagedPrivateEndpointModelProperties 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(ManagedPrivateEndpointModelProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedPrivateEndpointModelProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedPrivateEndpointModelProperties DeserializeManagedPrivateEndpointModelProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + GrafanaProvisioningState? provisioningState = default; + ResourceIdentifier privateLinkResourceId = default; + string privateLinkResourceRegion = default; + IList groupIds = default; + string requestMessage = default; + ManagedPrivateEndpointConnectionState connectionState = default; + Uri privateLinkServiceUri = default; + string privateLinkServicePrivateIP = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new GrafanaProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("privateLinkResourceId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateLinkResourceId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("privateLinkResourceRegion"u8)) + { + privateLinkResourceRegion = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("groupIds"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + groupIds = array; + continue; + } + if (prop.NameEquals("requestMessage"u8)) + { + requestMessage = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("connectionState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + connectionState = ManagedPrivateEndpointConnectionState.DeserializeManagedPrivateEndpointConnectionState(prop.Value, options); + continue; + } + if (prop.NameEquals("privateLinkServiceUrl"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateLinkServiceUri = new Uri(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("privateLinkServicePrivateIP"u8)) + { + privateLinkServicePrivateIP = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ManagedPrivateEndpointModelProperties( + provisioningState, + privateLinkResourceId, + privateLinkResourceRegion, + groupIds ?? new ChangeTrackingList(), + requestMessage, + connectionState, + privateLinkServiceUri, + privateLinkServicePrivateIP, + 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, AzureResourceManagerGrafanaContext.Default); + default: + throw new FormatException($"The model {nameof(ManagedPrivateEndpointModelProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ManagedPrivateEndpointModelProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ManagedPrivateEndpointModelProperties 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 DeserializeManagedPrivateEndpointModelProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedPrivateEndpointModelProperties)} 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelProperties.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelProperties.cs new file mode 100644 index 000000000000..ffe43a7dc3b9 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/ManagedPrivateEndpointModelProperties.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Grafana; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// Properties specific to the managed private endpoint. + internal partial class ManagedPrivateEndpointModelProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ManagedPrivateEndpointModelProperties() + { + GroupIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Provisioning state of the resource. + /// The ARM resource ID of the resource for which the managed private endpoint is pointing to. + /// The region of the resource to which the managed private endpoint is pointing to. + /// The group Ids of the managed private endpoint. + /// User input request message of the managed private endpoint. + /// The state of managed private endpoint connection. + /// The URL of the data store behind the private link service. It would be the URL in the Grafana data source configuration page without the protocol and port. + /// The private IP of private endpoint after approval. This property is empty before connection is approved. + /// Keeps track of any properties unknown to the library. + internal ManagedPrivateEndpointModelProperties(GrafanaProvisioningState? provisioningState, ResourceIdentifier privateLinkResourceId, string privateLinkResourceRegion, IList groupIds, string requestMessage, ManagedPrivateEndpointConnectionState connectionState, Uri privateLinkServiceUri, string privateLinkServicePrivateIP, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + PrivateLinkResourceId = privateLinkResourceId; + PrivateLinkResourceRegion = privateLinkResourceRegion; + GroupIds = groupIds; + RequestMessage = requestMessage; + ConnectionState = connectionState; + PrivateLinkServiceUri = privateLinkServiceUri; + PrivateLinkServicePrivateIP = privateLinkServicePrivateIP; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Provisioning state of the resource. + public GrafanaProvisioningState? ProvisioningState { get; } + + /// The ARM resource ID of the resource for which the managed private endpoint is pointing to. + public ResourceIdentifier PrivateLinkResourceId { get; set; } + + /// The region of the resource to which the managed private endpoint is pointing to. + public string PrivateLinkResourceRegion { get; set; } + + /// The group Ids of the managed private endpoint. + public IList GroupIds { get; } = new ChangeTrackingList(); + + /// User input request message of the managed private endpoint. + public string RequestMessage { get; set; } + + /// The state of managed private endpoint connection. + public ManagedPrivateEndpointConnectionState ConnectionState { get; } + + /// The URL of the data store behind the private link service. It would be the URL in the Grafana data source configuration page without the protocol and port. + public Uri PrivateLinkServiceUri { get; set; } + + /// The private IP of private endpoint after approval. This property is empty before connection is approved. + public string PrivateLinkServicePrivateIP { get; } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MarketplaceAutoRenew.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MarketplaceAutoRenew.cs index 06767c34bf70..1d9d5f763ea4 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MarketplaceAutoRenew.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MarketplaceAutoRenew.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { @@ -14,38 +15,55 @@ namespace Azure.ResourceManager.Grafana.Models public readonly partial struct MarketplaceAutoRenew : IEquatable { private readonly string _value; + private const string DisabledValue = "Disabled"; + private const string EnabledValue = "Enabled"; /// Initializes a new instance of . + /// The value. /// is null. public MarketplaceAutoRenew(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string DisabledValue = "Disabled"; - private const string EnabledValue = "Enabled"; + _value = value; + } - /// Disabled. + /// Gets the Disabled. public static MarketplaceAutoRenew Disabled { get; } = new MarketplaceAutoRenew(DisabledValue); - /// Enabled. + + /// Gets the Enabled. public static MarketplaceAutoRenew Enabled { get; } = new MarketplaceAutoRenew(EnabledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(MarketplaceAutoRenew left, MarketplaceAutoRenew 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 !=(MarketplaceAutoRenew left, MarketplaceAutoRenew right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator MarketplaceAutoRenew(string value) => new MarketplaceAutoRenew(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator MarketplaceAutoRenew?(string value) => value == null ? null : new MarketplaceAutoRenew(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is MarketplaceAutoRenew other && Equals(other); - /// + + /// public bool Equals(MarketplaceAutoRenew 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MarketplaceTrialQuota.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MarketplaceTrialQuota.Serialization.cs index 365af9618214..934066d601f9 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MarketplaceTrialQuota.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MarketplaceTrialQuota.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class MarketplaceTrialQuota : IUtf8JsonSerializable, IJsonModel + /// The allocation details of the per subscription free trial slot of the subscription. + public partial class MarketplaceTrialQuota : 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(MarketplaceTrialQuota)} does not support writing '{format}' format."); } - if (Optional.IsDefined(AvailablePromotion)) { writer.WritePropertyName("availablePromotion"u8); @@ -54,15 +55,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("trialEndAt"u8); writer.WriteStringValue(TrialEndOn.Value, "O"); } - 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,83 +72,89 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MarketplaceTrialQuota IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MarketplaceTrialQuota IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MarketplaceTrialQuota 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(MarketplaceTrialQuota)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeMarketplaceTrialQuota(document.RootElement, options); } - internal static MarketplaceTrialQuota DeserializeMarketplaceTrialQuota(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MarketplaceTrialQuota DeserializeMarketplaceTrialQuota(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } AvailablePromotion? availablePromotion = default; ResourceIdentifier grafanaResourceId = default; - DateTimeOffset? trialStartAt = default; - DateTimeOffset? trialEndAt = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DateTimeOffset? trialStartOn = default; + DateTimeOffset? trialEndOn = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("availablePromotion"u8)) + if (prop.NameEquals("availablePromotion"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - availablePromotion = new AvailablePromotion(property.Value.GetString()); + availablePromotion = new AvailablePromotion(prop.Value.GetString()); continue; } - if (property.NameEquals("grafanaResourceId"u8)) + if (prop.NameEquals("grafanaResourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - grafanaResourceId = new ResourceIdentifier(property.Value.GetString()); + grafanaResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("trialStartAt"u8)) + if (prop.NameEquals("trialStartAt"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - trialStartAt = property.Value.GetDateTimeOffset("O"); + trialStartOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("trialEndAt"u8)) + if (prop.NameEquals("trialEndAt"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - trialEndAt = property.Value.GetDateTimeOffset("O"); + trialEndOn = prop.Value.GetDateTimeOffset("O"); 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 MarketplaceTrialQuota(availablePromotion, grafanaResourceId, trialStartAt, trialEndAt, serializedAdditionalRawData); + return new MarketplaceTrialQuota(availablePromotion, grafanaResourceId, trialStartOn, trialEndOn, 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": @@ -157,15 +164,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - MarketplaceTrialQuota 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. + MarketplaceTrialQuota IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MarketplaceTrialQuota 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 DeserializeMarketplaceTrialQuota(document.RootElement, options); } default: @@ -173,6 +185,7 @@ MarketplaceTrialQuota IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MarketplaceTrialQuota.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MarketplaceTrialQuota.cs index 533f7950c6fa..440f5c3d8219 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MarketplaceTrialQuota.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MarketplaceTrialQuota.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.Grafana.Models /// The allocation details of the per subscription free trial slot of the subscription. public partial class MarketplaceTrialQuota { - /// - /// 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 MarketplaceTrialQuota() @@ -56,22 +27,25 @@ internal MarketplaceTrialQuota() /// Resource Id of the Grafana resource which is doing the trial. /// The date and time in UTC of when the trial starts. /// The date and time in UTC of when the trial ends. - /// Keeps track of any properties unknown to the library. - internal MarketplaceTrialQuota(AvailablePromotion? availablePromotion, ResourceIdentifier grafanaResourceId, DateTimeOffset? trialStartOn, DateTimeOffset? trialEndOn, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal MarketplaceTrialQuota(AvailablePromotion? availablePromotion, ResourceIdentifier grafanaResourceId, DateTimeOffset? trialStartOn, DateTimeOffset? trialEndOn, IDictionary additionalBinaryDataProperties) { AvailablePromotion = availablePromotion; GrafanaResourceId = grafanaResourceId; TrialStartOn = trialStartOn; TrialEndOn = trialEndOn; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Available enterprise promotion for the subscription. public AvailablePromotion? AvailablePromotion { get; } + /// Resource Id of the Grafana resource which is doing the trial. public ResourceIdentifier GrafanaResourceId { get; } + /// The date and time in UTC of when the trial starts. public DateTimeOffset? TrialStartOn { get; } + /// The date and time in UTC of when the trial ends. public DateTimeOffset? TrialEndOn { get; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MonitorWorkspaceIntegration.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MonitorWorkspaceIntegration.Serialization.cs index b954a1fe865a..572aecf61f64 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MonitorWorkspaceIntegration.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MonitorWorkspaceIntegration.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class MonitorWorkspaceIntegration : IUtf8JsonSerializable, IJsonModel + /// Integrations for Azure Monitor Workspace. + public partial class MonitorWorkspaceIntegration : 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(MonitorWorkspaceIntegration)} does not support writing '{format}' format."); } - if (Optional.IsDefined(MonitorWorkspaceResourceId)) { writer.WritePropertyName("azureMonitorWorkspaceResourceId"u8); writer.WriteStringValue(MonitorWorkspaceResourceId); } - 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,53 +57,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MonitorWorkspaceIntegration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MonitorWorkspaceIntegration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MonitorWorkspaceIntegration 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(MonitorWorkspaceIntegration)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeMonitorWorkspaceIntegration(document.RootElement, options); } - internal static MonitorWorkspaceIntegration DeserializeMonitorWorkspaceIntegration(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MonitorWorkspaceIntegration DeserializeMonitorWorkspaceIntegration(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - ResourceIdentifier azureMonitorWorkspaceResourceId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + ResourceIdentifier monitorWorkspaceResourceId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("azureMonitorWorkspaceResourceId"u8)) + if (prop.NameEquals("azureMonitorWorkspaceResourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - azureMonitorWorkspaceResourceId = new ResourceIdentifier(property.Value.GetString()); + monitorWorkspaceResourceId = new ResourceIdentifier(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 MonitorWorkspaceIntegration(azureMonitorWorkspaceResourceId, serializedAdditionalRawData); + return new MonitorWorkspaceIntegration(monitorWorkspaceResourceId, 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": @@ -112,15 +119,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - MonitorWorkspaceIntegration 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. + MonitorWorkspaceIntegration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MonitorWorkspaceIntegration 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 DeserializeMonitorWorkspaceIntegration(document.RootElement, options); } default: @@ -128,6 +140,7 @@ MonitorWorkspaceIntegration IPersistableModel.Creat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MonitorWorkspaceIntegration.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MonitorWorkspaceIntegration.cs index fef940767c7e..45b82fc57f23 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MonitorWorkspaceIntegration.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/MonitorWorkspaceIntegration.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.Grafana.Models /// Integrations for Azure Monitor Workspace. public partial class MonitorWorkspaceIntegration { - /// - /// 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 MonitorWorkspaceIntegration() @@ -53,11 +24,11 @@ public MonitorWorkspaceIntegration() /// Initializes a new instance of . /// The resource Id of the connected Azure Monitor Workspace. - /// Keeps track of any properties unknown to the library. - internal MonitorWorkspaceIntegration(ResourceIdentifier monitorWorkspaceResourceId, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal MonitorWorkspaceIntegration(ResourceIdentifier monitorWorkspaceResourceId, IDictionary additionalBinaryDataProperties) { MonitorWorkspaceResourceId = monitorWorkspaceResourceId; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The resource Id of the connected Azure Monitor Workspace. diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/PrivateEndpoint.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/PrivateEndpoint.Serialization.cs new file mode 100644 index 000000000000..3eecb25fb016 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/PrivateEndpoint.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.Grafana; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// The private endpoint resource. + internal partial class PrivateEndpoint : 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(PrivateEndpoint)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + 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. + PrivateEndpoint IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PrivateEndpoint 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(PrivateEndpoint)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePrivateEndpoint(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PrivateEndpoint DeserializePrivateEndpoint(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PrivateEndpoint(id, 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, AzureResourceManagerGrafanaContext.Default); + default: + throw new FormatException($"The model {nameof(PrivateEndpoint)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PrivateEndpoint IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PrivateEndpoint 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 DeserializePrivateEndpoint(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PrivateEndpoint)} 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/PrivateEndpoint.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/PrivateEndpoint.cs new file mode 100644 index 000000000000..114f04d0b93c --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/PrivateEndpoint.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// The private endpoint resource. + internal partial class PrivateEndpoint + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public PrivateEndpoint() + { + } + + /// Initializes a new instance of . + /// The resource identifier of the private endpoint. + /// Keeps track of any properties unknown to the library. + internal PrivateEndpoint(string id, IDictionary additionalBinaryDataProperties) + { + Id = id; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The resource identifier of the private endpoint. + public string Id { get; } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/PrivateEndpointConnectionProperties.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/PrivateEndpointConnectionProperties.Serialization.cs new file mode 100644 index 000000000000..43fd5c6eb42b --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/PrivateEndpointConnectionProperties.Serialization.cs @@ -0,0 +1,210 @@ +// 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.Grafana; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// Properties of the PrivateEndpointConnectProperties. + internal partial class PrivateEndpointConnectionProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PrivateEndpointConnectionProperties() + { + } + + /// 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(PrivateEndpointConnectionProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(PrivateEndpoint)) + { + writer.WritePropertyName("privateEndpoint"u8); + writer.WriteObjectValue(PrivateEndpoint, options); + } + writer.WritePropertyName("privateLinkServiceConnectionState"u8); + writer.WriteObjectValue(ConnectionState, options); + if (Optional.IsCollectionDefined(GroupIds)) + { + writer.WritePropertyName("groupIds"u8); + writer.WriteStartArray(); + foreach (string item in GroupIds) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + 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. + PrivateEndpointConnectionProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PrivateEndpointConnectionProperties 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(PrivateEndpointConnectionProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePrivateEndpointConnectionProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PrivateEndpointConnectionProperties DeserializePrivateEndpointConnectionProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + PrivateEndpoint privateEndpoint = default; + GrafanaPrivateLinkServiceConnectionState connectionState = default; + IList groupIds = default; + GrafanaPrivateEndpointConnectionProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("privateEndpoint"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateEndpoint = PrivateEndpoint.DeserializePrivateEndpoint(prop.Value, options); + continue; + } + if (prop.NameEquals("privateLinkServiceConnectionState"u8)) + { + connectionState = GrafanaPrivateLinkServiceConnectionState.DeserializeGrafanaPrivateLinkServiceConnectionState(prop.Value, options); + continue; + } + if (prop.NameEquals("groupIds"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + groupIds = array; + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new GrafanaPrivateEndpointConnectionProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PrivateEndpointConnectionProperties(privateEndpoint, connectionState, groupIds ?? new ChangeTrackingList(), 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, AzureResourceManagerGrafanaContext.Default); + default: + throw new FormatException($"The model {nameof(PrivateEndpointConnectionProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PrivateEndpointConnectionProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PrivateEndpointConnectionProperties 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 DeserializePrivateEndpointConnectionProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PrivateEndpointConnectionProperties)} 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/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/PrivateEndpointConnectionProperties.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/PrivateEndpointConnectionProperties.cs new file mode 100644 index 000000000000..3bd08f51d88a --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/PrivateEndpointConnectionProperties.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Grafana; + +namespace Azure.ResourceManager.Grafana.Models +{ + /// Properties of the PrivateEndpointConnectProperties. + internal partial class PrivateEndpointConnectionProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// A collection of information about the state of the connection between service consumer and provider. + /// is null. + public PrivateEndpointConnectionProperties(GrafanaPrivateLinkServiceConnectionState connectionState) + { + Argument.AssertNotNull(connectionState, nameof(connectionState)); + + ConnectionState = connectionState; + GroupIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The resource of private end point. + /// A collection of information about the state of the connection between service consumer and provider. + /// The private endpoint connection group ids. + /// The provisioning state of the private endpoint connection resource. + /// Keeps track of any properties unknown to the library. + internal PrivateEndpointConnectionProperties(PrivateEndpoint privateEndpoint, GrafanaPrivateLinkServiceConnectionState connectionState, IList groupIds, GrafanaPrivateEndpointConnectionProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + PrivateEndpoint = privateEndpoint; + ConnectionState = connectionState; + GroupIds = groupIds; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The resource of private end point. + internal PrivateEndpoint PrivateEndpoint { get; set; } + + /// A collection of information about the state of the connection between service consumer and provider. + public GrafanaPrivateLinkServiceConnectionState ConnectionState { get; set; } + + /// The private endpoint connection group ids. + public IList GroupIds { get; } = new ChangeTrackingList(); + + /// The provisioning state of the private endpoint connection resource. + public GrafanaPrivateEndpointConnectionProvisioningState? ProvisioningState { get; } + + /// The resource identifier of the private endpoint. + public string PrivateEndpointId + { + get + { + return PrivateEndpoint is null ? default : PrivateEndpoint.Id; + } + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SaasSubscriptionDetails.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SaasSubscriptionDetails.Serialization.cs index acf2b34642d0..b989f68b7a47 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SaasSubscriptionDetails.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SaasSubscriptionDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class SaasSubscriptionDetails : IUtf8JsonSerializable, IJsonModel + /// SaaS subscription details of a Grafana instance. + public partial class SaasSubscriptionDetails : 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(SaasSubscriptionDetails)} does not support writing '{format}' format."); } - if (Optional.IsDefined(PlanId)) { writer.WritePropertyName("planId"u8); @@ -54,15 +54,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("term"u8); writer.WriteObjectValue(Term, 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); } @@ -71,22 +71,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SaasSubscriptionDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SaasSubscriptionDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SaasSubscriptionDetails 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(SaasSubscriptionDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSaasSubscriptionDetails(document.RootElement, options); } - internal static SaasSubscriptionDetails DeserializeSaasSubscriptionDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SaasSubscriptionDetails DeserializeSaasSubscriptionDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -95,47 +100,48 @@ internal static SaasSubscriptionDetails DeserializeSaasSubscriptionDetails(JsonE string offerId = default; string publisherId = default; SubscriptionTerm term = 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("planId"u8)) + if (prop.NameEquals("planId"u8)) { - planId = property.Value.GetString(); + planId = prop.Value.GetString(); continue; } - if (property.NameEquals("offerId"u8)) + if (prop.NameEquals("offerId"u8)) { - offerId = property.Value.GetString(); + offerId = prop.Value.GetString(); continue; } - if (property.NameEquals("publisherId"u8)) + if (prop.NameEquals("publisherId"u8)) { - publisherId = property.Value.GetString(); + publisherId = prop.Value.GetString(); continue; } - if (property.NameEquals("term"u8)) + if (prop.NameEquals("term"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - term = SubscriptionTerm.DeserializeSubscriptionTerm(property.Value, options); + term = SubscriptionTerm.DeserializeSubscriptionTerm(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 SaasSubscriptionDetails(planId, offerId, publisherId, term, serializedAdditionalRawData); + return new SaasSubscriptionDetails(planId, offerId, publisherId, term, 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(ModelReaderWriterOpt } } - SaasSubscriptionDetails 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. + SaasSubscriptionDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SaasSubscriptionDetails 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 DeserializeSaasSubscriptionDetails(document.RootElement, options); } default: @@ -161,6 +172,7 @@ SaasSubscriptionDetails IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SaasSubscriptionDetails.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SaasSubscriptionDetails.cs index bcb8ebbddfe0..2ae598e9deb7 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SaasSubscriptionDetails.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SaasSubscriptionDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.Grafana.Models /// SaaS subscription details of a Grafana instance. public partial class SaasSubscriptionDetails { - /// - /// 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 SaasSubscriptionDetails() @@ -55,22 +26,25 @@ internal SaasSubscriptionDetails() /// The offer Id of the SaaS subscription. /// The publisher Id of the SaaS subscription. /// The billing term of the SaaS Subscription. - /// Keeps track of any properties unknown to the library. - internal SaasSubscriptionDetails(string planId, string offerId, string publisherId, SubscriptionTerm term, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SaasSubscriptionDetails(string planId, string offerId, string publisherId, SubscriptionTerm term, IDictionary additionalBinaryDataProperties) { PlanId = planId; OfferId = offerId; PublisherId = publisherId; Term = term; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The plan Id of the SaaS subscription. public string PlanId { get; } + /// The offer Id of the SaaS subscription. public string OfferId { get; } + /// The publisher Id of the SaaS subscription. public string PublisherId { get; } + /// The billing term of the SaaS Subscription. public SubscriptionTerm Term { get; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SubscriptionTerm.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SubscriptionTerm.Serialization.cs index 6e94dbb0d105..440f3b6c1da2 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SubscriptionTerm.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SubscriptionTerm.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - public partial class SubscriptionTerm : IUtf8JsonSerializable, IJsonModel + /// The current billing term of the SaaS Subscription. + public partial class SubscriptionTerm : 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, 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(SubscriptionTerm)} does not support writing '{format}' format."); } - if (Optional.IsDefined(TermUnit)) { writer.WritePropertyName("termUnit"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("endDate"u8); writer.WriteStringValue(EndOn.Value, "O"); } - 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,69 +66,75 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SubscriptionTerm IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SubscriptionTerm IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SubscriptionTerm 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(SubscriptionTerm)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSubscriptionTerm(document.RootElement, options); } - internal static SubscriptionTerm DeserializeSubscriptionTerm(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SubscriptionTerm DeserializeSubscriptionTerm(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string termUnit = default; - DateTimeOffset? startDate = default; - DateTimeOffset? endDate = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DateTimeOffset? startOn = default; + DateTimeOffset? endOn = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("termUnit"u8)) + if (prop.NameEquals("termUnit"u8)) { - termUnit = property.Value.GetString(); + termUnit = prop.Value.GetString(); continue; } - if (property.NameEquals("startDate"u8)) + if (prop.NameEquals("startDate"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - startDate = property.Value.GetDateTimeOffset("O"); + startOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("endDate"u8)) + if (prop.NameEquals("endDate"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - endDate = property.Value.GetDateTimeOffset("O"); + endOn = prop.Value.GetDateTimeOffset("O"); 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 SubscriptionTerm(termUnit, startDate, endDate, serializedAdditionalRawData); + return new SubscriptionTerm(termUnit, startOn, endOn, 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 +144,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - SubscriptionTerm 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. + SubscriptionTerm IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SubscriptionTerm 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 DeserializeSubscriptionTerm(document.RootElement, options); } default: @@ -154,6 +165,7 @@ SubscriptionTerm IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SubscriptionTerm.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SubscriptionTerm.cs index 6d237afa7e63..5882963a6496 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SubscriptionTerm.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/SubscriptionTerm.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.Grafana.Models /// The current billing term of the SaaS Subscription. public partial class SubscriptionTerm { - /// - /// 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 SubscriptionTerm() @@ -54,19 +25,21 @@ internal SubscriptionTerm() /// The unit of the billing term. /// The date and time in UTC of when the billing term starts. /// The date and time in UTC of when the billing term ends. - /// Keeps track of any properties unknown to the library. - internal SubscriptionTerm(string termUnit, DateTimeOffset? startOn, DateTimeOffset? endOn, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SubscriptionTerm(string termUnit, DateTimeOffset? startOn, DateTimeOffset? endOn, IDictionary additionalBinaryDataProperties) { TermUnit = termUnit; StartOn = startOn; EndOn = endOn; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The unit of the billing term. public string TermUnit { get; } + /// The date and time in UTC of when the billing term starts. public DateTimeOffset? StartOn { get; } + /// The date and time in UTC of when the billing term ends. public DateTimeOffset? EndOn { get; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/UnifiedAlertingScreenshots.Serialization.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/UnifiedAlertingScreenshots.Serialization.cs index def01c626b87..d81b9b9b1d71 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/UnifiedAlertingScreenshots.Serialization.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/UnifiedAlertingScreenshots.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.Grafana; namespace Azure.ResourceManager.Grafana.Models { - internal partial class UnifiedAlertingScreenshots : IUtf8JsonSerializable, IJsonModel + /// Grafana Unified Alerting Screenshots settings. + internal partial class UnifiedAlertingScreenshots : 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 +29,25 @@ 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(UnifiedAlertingScreenshots)} does not support writing '{format}' format."); } - if (Optional.IsDefined(IsCaptureEnabled)) { writer.WritePropertyName("captureEnabled"u8); writer.WriteBooleanValue(IsCaptureEnabled.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); } @@ -56,53 +56,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - UnifiedAlertingScreenshots IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + UnifiedAlertingScreenshots IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UnifiedAlertingScreenshots 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(UnifiedAlertingScreenshots)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeUnifiedAlertingScreenshots(document.RootElement, options); } - internal static UnifiedAlertingScreenshots DeserializeUnifiedAlertingScreenshots(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnifiedAlertingScreenshots DeserializeUnifiedAlertingScreenshots(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - bool? captureEnabled = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + bool? isCaptureEnabled = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("captureEnabled"u8)) + if (prop.NameEquals("captureEnabled"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - captureEnabled = property.Value.GetBoolean(); + isCaptureEnabled = prop.Value.GetBoolean(); 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 UnifiedAlertingScreenshots(captureEnabled, serializedAdditionalRawData); + return new UnifiedAlertingScreenshots(isCaptureEnabled, 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": @@ -112,15 +118,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriter } } - UnifiedAlertingScreenshots 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. + UnifiedAlertingScreenshots IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UnifiedAlertingScreenshots 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 DeserializeUnifiedAlertingScreenshots(document.RootElement, options); } default: @@ -128,6 +139,7 @@ UnifiedAlertingScreenshots IPersistableModel.Create( } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/UnifiedAlertingScreenshots.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/UnifiedAlertingScreenshots.cs index f722b11437d5..beb1f8e51a40 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/UnifiedAlertingScreenshots.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/Models/UnifiedAlertingScreenshots.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.Grafana.Models /// Grafana Unified Alerting Screenshots settings. internal partial class UnifiedAlertingScreenshots { - /// - /// 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 UnifiedAlertingScreenshots() @@ -52,11 +23,11 @@ public UnifiedAlertingScreenshots() /// Initializes a new instance of . /// Set to false to disable capture screenshot in Unified Alert due to performance issue. - /// Keeps track of any properties unknown to the library. - internal UnifiedAlertingScreenshots(bool? isCaptureEnabled, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal UnifiedAlertingScreenshots(bool? isCaptureEnabled, IDictionary additionalBinaryDataProperties) { IsCaptureEnabled = isCaptureEnabled; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Set to false to disable capture screenshot in Unified Alert due to performance issue. diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ProviderConstants.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ProviderConstants.cs index 7d0036cff285..e63a9b45d603 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ProviderConstants.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/ProviderConstants.cs @@ -9,8 +9,9 @@ namespace Azure.ResourceManager.Grafana { - 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/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/DashboardDefinitionsRestOperations.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/DashboardDefinitionsRestOperations.cs new file mode 100644 index 000000000000..b86822baf542 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/DashboardDefinitionsRestOperations.cs @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Grafana +{ + internal partial class DashboardDefinitions + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of DashboardDefinitions for mocking. + protected DashboardDefinitions() + { + } + + /// Initializes a new instance of DashboardDefinitions. + /// 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 DashboardDefinitions(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string dashboardName, string definitionName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Dashboard/dashboards/", false); + uri.AppendPath(dashboardName, true); + uri.AppendPath("/dashboardDefinitions/", false); + uri.AppendPath(definitionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string dashboardName, string definitionName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Dashboard/dashboards/", false); + uri.AppendPath(dashboardName, true); + uri.AppendPath("/dashboardDefinitions/", false); + uri.AppendPath(definitionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string dashboardName, string definitionName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Dashboard/dashboards/", false); + uri.AppendPath(dashboardName, true); + uri.AppendPath("/dashboardDefinitions/", false); + uri.AppendPath(definitionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetAllRequest(string subscriptionId, string resourceGroupName, string dashboardName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Dashboard/dashboards/", false); + uri.AppendPath(dashboardName, true); + uri.AppendPath("/dashboardDefinitions", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, string subscriptionId, string resourceGroupName, string dashboardName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/IntegrationFabricsRestOperations.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/IntegrationFabricsRestOperations.cs index 19ce27b14699..ac63f678f1f5 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/IntegrationFabricsRestOperations.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/IntegrationFabricsRestOperations.cs @@ -6,143 +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.Grafana.Models; namespace Azure.ResourceManager.Grafana { - internal partial class IntegrationFabricsRestOperations + internal partial class IntegrationFabrics { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of IntegrationFabricsRestOperations. - /// 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 IntegrationFabricsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of IntegrationFabrics for mocking. + protected IntegrationFabrics() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-08-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName) + /// Initializes a new instance of IntegrationFabrics. + /// 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 IntegrationFabrics(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("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/integrationFabrics/", false); - uri.AppendPath(integrationFabricName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/integrationFabrics/", false); - uri.AppendPath(integrationFabricName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Get a IntegrationFabric. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The integration fabric name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, workspaceName, integrationFabricName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - GrafanaIntegrationFabricData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = GrafanaIntegrationFabricData.DeserializeGrafanaIntegrationFabricData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((GrafanaIntegrationFabricData)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 a IntegrationFabric. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The integration fabric name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, workspaceName, integrationFabricName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - GrafanaIntegrationFabricData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = GrafanaIntegrationFabricData.DeserializeGrafanaIntegrationFabricData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((GrafanaIntegrationFabricData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCreateRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, GrafanaIntegrationFabricData data) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -153,15 +54,17 @@ internal RequestUriBuilder CreateCreateRequestUri(string subscriptionId, string uri.AppendPath("/integrationFabrics/", false); uri.AppendPath(integrationFabricName, 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 subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, GrafanaIntegrationFabricData data) + internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -172,96 +75,19 @@ internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceG uri.AppendPath("/integrationFabrics/", false); uri.AppendPath(integrationFabricName, 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.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Create a IntegrationFabric. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The integration fabric name of Azure Managed Grafana. - /// The to use. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task CreateAsync(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, GrafanaIntegrationFabricData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, workspaceName, integrationFabricName, 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); - } - } - - /// Create a IntegrationFabric. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The integration fabric name of Azure Managed Grafana. - /// The to use. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Create(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, GrafanaIntegrationFabricData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, workspaceName, integrationFabricName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, GrafanaIntegrationFabricPatch patch) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/integrationFabrics/", false); - uri.AppendPath(integrationFabricName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, GrafanaIntegrationFabricPatch patch) + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -272,96 +98,19 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath("/integrationFabrics/", false); uri.AppendPath(integrationFabricName, 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.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Update a IntegrationFabric. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The integration fabric name of Azure Managed Grafana. - /// The to use. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, GrafanaIntegrationFabricPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, workspaceName, integrationFabricName, 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 a IntegrationFabric. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The integration fabric name of Azure Managed Grafana. - /// The to use. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Update(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, GrafanaIntegrationFabricPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, workspaceName, integrationFabricName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 202: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, RequestContext context) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/integrationFabrics/", false); - uri.AppendPath(integrationFabricName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -372,86 +121,16 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/integrationFabrics/", false); uri.AppendPath(integrationFabricName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete a IntegrationFabric. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The integration fabric name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, workspaceName, integrationFabricName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a IntegrationFabric. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The integration fabric name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Delete(string subscriptionId, string resourceGroupName, string workspaceName, string integrationFabricName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(integrationFabricName, nameof(integrationFabricName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, workspaceName, integrationFabricName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string workspaceName) + internal HttpMessage CreateGetAllRequest(string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/integrationFabrics", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string workspaceName) - { - 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -461,152 +140,24 @@ internal HttpMessage CreateListRequest(string subscriptionId, string resourceGro uri.AppendPath(workspaceName, true); uri.AppendPath("/integrationFabrics", 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.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// List IntegrationFabric resources by ManagedGrafana. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListAsync(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, workspaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - IntegrationFabricListResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = IntegrationFabricListResponse.DeserializeIntegrationFabricListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List IntegrationFabric resources by ManagedGrafana. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response List(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, workspaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - IntegrationFabricListResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = IntegrationFabricListResponse.DeserializeIntegrationFabricListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName) + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, string subscriptionId, string resourceGroupName, string workspaceName, 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; } - - /// List IntegrationFabric resources by ManagedGrafana. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, workspaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - IntegrationFabricListResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = IntegrationFabricListResponse.DeserializeIntegrationFabricListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List IntegrationFabric resources by ManagedGrafana. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, workspaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - IntegrationFabricListResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = IntegrationFabricListResponse.DeserializeIntegrationFabricListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/ManagedDashboardsRestOperations.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/ManagedDashboardsRestOperations.cs index d0bb3b01fafe..c5d5f60941f8 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/ManagedDashboardsRestOperations.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/ManagedDashboardsRestOperations.cs @@ -6,135 +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.Grafana.Models; namespace Azure.ResourceManager.Grafana { - internal partial class ManagedDashboardsRestOperations + internal partial class ManagedDashboards { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of ManagedDashboardsRestOperations. - /// 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 ManagedDashboardsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of ManagedDashboards for mocking. + protected ManagedDashboards() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-08-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string dashboardName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/dashboards/", false); - uri.AppendPath(dashboardName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; } - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string dashboardName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/dashboards/", false); - uri.AppendPath(dashboardName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Get the properties of a specific dashboard for grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure Managed Dashboard. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string dashboardName, CancellationToken cancellationToken = default) + /// Initializes a new instance of ManagedDashboards. + /// 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 ManagedDashboards(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, dashboardName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedDashboardData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedDashboardData.DeserializeManagedDashboardData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((ManagedDashboardData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Get the properties of a specific dashboard for grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure Managed Dashboard. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string dashboardName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, dashboardName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedDashboardData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedDashboardData.DeserializeManagedDashboardData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((ManagedDashboardData)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 subscriptionId, string resourceGroupName, string dashboardName, ManagedDashboardData data) + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string dashboardName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -143,15 +52,17 @@ internal RequestUriBuilder CreateCreateRequestUri(string subscriptionId, string uri.AppendPath("/providers/Microsoft.Dashboard/dashboards/", false); uri.AppendPath(dashboardName, 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 subscriptionId, string resourceGroupName, string dashboardName, ManagedDashboardData data) + internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string dashboardName, 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -160,90 +71,19 @@ internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.Dashboard/dashboards/", false); uri.AppendPath(dashboardName, 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.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Create or update a dashboard for grafana resource. This API is idempotent, so user can either create a new dashboard or update an existing dashboard. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure Managed Dashboard. - /// The to use. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task CreateAsync(string subscriptionId, string resourceGroupName, string dashboardName, ManagedDashboardData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, dashboardName, 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); - } - } - - /// Create or update a dashboard for grafana resource. This API is idempotent, so user can either create a new dashboard or update an existing dashboard. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure Managed Dashboard. - /// The to use. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Create(string subscriptionId, string resourceGroupName, string dashboardName, ManagedDashboardData data, CancellationToken cancellationToken = default) + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string dashboardName, RequestContent content, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, dashboardName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string dashboardName, ManagedDashboardPatch patch) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/dashboards/", false); - uri.AppendPath(dashboardName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string dashboardName, ManagedDashboardPatch patch) - { - 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -252,98 +92,19 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.Dashboard/dashboards/", false); uri.AppendPath(dashboardName, 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.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Update a dashboard for Grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure Managed Dashboard. - /// The to use. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> UpdateAsync(string subscriptionId, string resourceGroupName, string dashboardName, ManagedDashboardPatch patch, CancellationToken cancellationToken = default) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string dashboardName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, dashboardName, patch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedDashboardData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedDashboardData.DeserializeManagedDashboardData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Update a dashboard for Grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure Managed Dashboard. - /// The to use. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Update(string subscriptionId, string resourceGroupName, string dashboardName, ManagedDashboardPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, dashboardName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedDashboardData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedDashboardData.DeserializeManagedDashboardData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string dashboardName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/dashboards/", false); - uri.AppendPath(dashboardName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string dashboardName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -352,80 +113,16 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.Dashboard/dashboards/", false); uri.AppendPath(dashboardName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete a dashboard for Grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure Managed Dashboard. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string dashboardName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetAllRequest(string subscriptionId, string resourceGroupName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, dashboardName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a dashboard for Grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure Managed Dashboard. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Delete(string subscriptionId, string resourceGroupName, string dashboardName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(dashboardName, nameof(dashboardName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, dashboardName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/dashboards", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName) - { - 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -433,298 +130,52 @@ internal HttpMessage CreateListRequest(string subscriptionId, string resourceGro uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Dashboard/dashboards", 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.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// List all resources of dashboards under the specified resource group. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ListAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, string subscriptionId, string resourceGroupName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedDashboardListResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedDashboardListResponse.DeserializeManagedDashboardListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all resources of dashboards under the specified resource group. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public Response List(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedDashboardListResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedDashboardListResponse.DeserializeManagedDashboardListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Dashboard/dashboards", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + 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 CreateListBySubscriptionRequest(string subscriptionId) + internal HttpMessage CreateGetBySubscriptionRequest(string subscriptionId, 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/providers/Microsoft.Dashboard/dashboards", 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); - return message; - } - - /// List all resources of dashboards under the specified subscription. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListBySubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionRequest(subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedDashboardListResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedDashboardListResponse.DeserializeManagedDashboardListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all resources of dashboards under the specified subscription. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response ListBySubscription(string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionRequest(subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedDashboardListResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedDashboardListResponse.DeserializeManagedDashboardListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Headers.SetValue("Accept", "application/json"); return message; } - /// List all resources of dashboards under the specified resource group. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedDashboardListResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedDashboardListResponse.DeserializeManagedDashboardListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all resources of dashboards under the specified resource group. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetBySubscriptionRequest(Uri nextPage, string subscriptionId, RequestContext context) { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedDashboardListResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedDashboardListResponse.DeserializeManagedDashboardListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId) - { - 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; } - - /// List all resources of dashboards under the specified subscription. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedDashboardListResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedDashboardListResponse.DeserializeManagedDashboardListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all resources of dashboards under the specified subscription. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedDashboardListResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedDashboardListResponse.DeserializeManagedDashboardListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/ManagedGrafanasRestOperations.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/ManagedGrafanasRestOperations.cs index c59ac82a9d97..167a24d0276c 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/ManagedGrafanasRestOperations.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/ManagedGrafanasRestOperations.cs @@ -6,135 +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.Grafana.Models; namespace Azure.ResourceManager.Grafana { - internal partial class ManagedGrafanasRestOperations + internal partial class ManagedGrafanas { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of ManagedGrafanasRestOperations. - /// 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 ManagedGrafanasRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of ManagedGrafanas for mocking. + protected ManagedGrafanas() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-08-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string workspaceName) + /// Initializes a new instance of ManagedGrafanas. + /// 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 ManagedGrafanas(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("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string workspaceName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Get the properties of a specific workspace for Grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, workspaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedGrafanaData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedGrafanaData.DeserializeManagedGrafanaData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((ManagedGrafanaData)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 properties of a specific workspace for Grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, workspaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedGrafanaData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedGrafanaData.DeserializeManagedGrafanaData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((ManagedGrafanaData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCreateRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, ManagedGrafanaData data) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -143,15 +52,17 @@ internal RequestUriBuilder CreateCreateRequestUri(string subscriptionId, string uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); uri.AppendPath(workspaceName, 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 subscriptionId, string resourceGroupName, string workspaceName, ManagedGrafanaData data) + internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string workspaceName, 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -160,90 +71,19 @@ internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); uri.AppendPath(workspaceName, 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.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new grafana or update an existing grafana. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The to use. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task CreateAsync(string subscriptionId, string resourceGroupName, string workspaceName, ManagedGrafanaData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, workspaceName, 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); - } - } - - /// Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new grafana or update an existing grafana. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The to use. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Create(string subscriptionId, string resourceGroupName, string workspaceName, ManagedGrafanaData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, workspaceName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, ManagedGrafanaPatch patch) + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string workspaceName, RequestContent content, RequestContext context) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string workspaceName, ManagedGrafanaPatch patch) - { - 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -252,90 +92,19 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); uri.AppendPath(workspaceName, 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.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Update a workspace for Grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The to use. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string workspaceName, ManagedGrafanaPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, workspaceName, 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 a workspace for Grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The to use. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Update(string subscriptionId, string resourceGroupName, string workspaceName, ManagedGrafanaPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, workspaceName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 202: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string workspaceName) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string workspaceName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -344,82 +113,16 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); uri.AppendPath(workspaceName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete a workspace for Grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, workspaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a workspace for Grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Delete(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetByResourceGroupRequest(string subscriptionId, string resourceGroupName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, workspaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName) - { - 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -427,165 +130,57 @@ internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, str uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Dashboard/grafana", 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.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// List all resources of workspaces for Grafana under the specified resource group. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedGrafanaListResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedGrafanaListResponse.DeserializeManagedGrafanaListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all resources of workspaces for Grafana under the specified resource group. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetByResourceGroupRequest(Uri nextPage, string subscriptionId, string resourceGroupName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedGrafanaListResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedGrafanaListResponse.DeserializeManagedGrafanaListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListRequestUri(string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + 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 CreateListRequest(string subscriptionId) + internal HttpMessage CreateGetAllRequest(string subscriptionId, 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/providers/Microsoft.Dashboard/grafana", 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.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// List all resources of workspaces for Grafana under the specified subscription. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListAsync(string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListRequest(subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedGrafanaListResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedGrafanaListResponse.DeserializeManagedGrafanaListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all resources of workspaces for Grafana under the specified subscription. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response List(string subscriptionId, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, string subscriptionId, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListRequest(subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedGrafanaListResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedGrafanaListResponse.DeserializeManagedGrafanaListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCheckEnterpriseDetailsRequestUri(string subscriptionId, string resourceGroupName, string workspaceName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/checkEnterpriseDetails", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + 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 CreateCheckEnterpriseDetailsRequest(string subscriptionId, string resourceGroupName, string workspaceName) + internal HttpMessage CreateCheckEnterpriseDetailsRequest(string subscriptionId, string resourceGroupName, string workspaceName, 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); @@ -595,91 +190,17 @@ internal HttpMessage CreateCheckEnterpriseDetailsRequest(string subscriptionId, uri.AppendPath(workspaceName, true); uri.AppendPath("/checkEnterpriseDetails", 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; } - /// Retrieve enterprise add-on details information. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> CheckEnterpriseDetailsAsync(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) + internal HttpMessage CreateFetchAvailablePluginsRequest(string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateCheckEnterpriseDetailsRequest(subscriptionId, resourceGroupName, workspaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - EnterpriseDetails value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = EnterpriseDetails.DeserializeEnterpriseDetails(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Retrieve enterprise add-on details information. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response CheckEnterpriseDetails(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateCheckEnterpriseDetailsRequest(subscriptionId, resourceGroupName, workspaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - EnterpriseDetails value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = EnterpriseDetails.DeserializeEnterpriseDetails(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateFetchAvailablePluginsRequestUri(string subscriptionId, string resourceGroupName, string workspaceName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/fetchAvailablePlugins", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateFetchAvailablePluginsRequest(string subscriptionId, string resourceGroupName, string workspaceName) - { - 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); @@ -689,73 +210,17 @@ internal HttpMessage CreateFetchAvailablePluginsRequest(string subscriptionId, s uri.AppendPath(workspaceName, true); uri.AppendPath("/fetchAvailablePlugins", 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; } - /// A synchronous resource action. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> FetchAvailablePluginsAsync(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateFetchAvailablePluginsRequest(subscriptionId, resourceGroupName, workspaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - GrafanaAvailablePluginListResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = GrafanaAvailablePluginListResponse.DeserializeGrafanaAvailablePluginListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// A synchronous resource action. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response FetchAvailablePlugins(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateFetchAvailablePluginsRequest(subscriptionId, resourceGroupName, workspaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - GrafanaAvailablePluginListResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = GrafanaAvailablePluginListResponse.DeserializeGrafanaAvailablePluginListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateRefreshManagedPrivateEndpointRequestUri(string subscriptionId, string resourceGroupName, string workspaceName) + internal HttpMessage CreateRefreshManagedPrivateEndpointRequest(string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -765,233 +230,11 @@ internal RequestUriBuilder CreateRefreshManagedPrivateEndpointRequestUri(string uri.AppendPath(workspaceName, true); uri.AppendPath("/refreshManagedPrivateEndpoints", false); uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateRefreshManagedPrivateEndpointRequest(string subscriptionId, string resourceGroupName, string workspaceName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/refreshManagedPrivateEndpoints", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - _userAgent.Apply(message); - return message; - } - - /// Refresh and sync managed private endpoints of a grafana resource to latest state. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task RefreshManagedPrivateEndpointAsync(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateRefreshManagedPrivateEndpointRequest(subscriptionId, resourceGroupName, workspaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 200: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Refresh and sync managed private endpoints of a grafana resource to latest state. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response RefreshManagedPrivateEndpoint(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateRefreshManagedPrivateEndpointRequest(subscriptionId, resourceGroupName, workspaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 200: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// List all resources of workspaces for Grafana under the specified resource group. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedGrafanaListResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedGrafanaListResponse.DeserializeManagedGrafanaListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all resources of workspaces for Grafana under the specified resource group. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedGrafanaListResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedGrafanaListResponse.DeserializeManagedGrafanaListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Post; return message; } - - /// List all resources of workspaces for Grafana under the specified subscription. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedGrafanaListResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedGrafanaListResponse.DeserializeManagedGrafanaListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all resources of workspaces for Grafana under the specified subscription. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response ListNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedGrafanaListResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedGrafanaListResponse.DeserializeManagedGrafanaListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/ManagedPrivateEndpointModelsRestOperations.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/ManagedPrivateEndpointModelsRestOperations.cs index 9616caa9fead..821d10d275ca 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/ManagedPrivateEndpointModelsRestOperations.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/ManagedPrivateEndpointModelsRestOperations.cs @@ -6,143 +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.Grafana.Models; namespace Azure.ResourceManager.Grafana { - internal partial class ManagedPrivateEndpointModelsRestOperations + internal partial class ManagedPrivateEndpointModels { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of ManagedPrivateEndpointModelsRestOperations. - /// 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 ManagedPrivateEndpointModelsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of ManagedPrivateEndpointModels for mocking. + protected ManagedPrivateEndpointModels() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-08-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName) + /// Initializes a new instance of ManagedPrivateEndpointModels. + /// 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 ManagedPrivateEndpointModels(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("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/managedPrivateEndpoints/", false); - uri.AppendPath(managedPrivateEndpointName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/managedPrivateEndpoints/", false); - uri.AppendPath(managedPrivateEndpointName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Get a specific managed private endpoint of a grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The managed private endpoint name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, workspaceName, managedPrivateEndpointName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedPrivateEndpointModelData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedPrivateEndpointModelData.DeserializeManagedPrivateEndpointModelData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((ManagedPrivateEndpointModelData)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 a specific managed private endpoint of a grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The managed private endpoint name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, workspaceName, managedPrivateEndpointName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedPrivateEndpointModelData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedPrivateEndpointModelData.DeserializeManagedPrivateEndpointModelData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((ManagedPrivateEndpointModelData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCreateRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, ManagedPrivateEndpointModelData data) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -153,15 +54,17 @@ internal RequestUriBuilder CreateCreateRequestUri(string subscriptionId, string uri.AppendPath("/managedPrivateEndpoints/", false); uri.AppendPath(managedPrivateEndpointName, 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 subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, ManagedPrivateEndpointModelData data) + internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -172,96 +75,19 @@ internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceG uri.AppendPath("/managedPrivateEndpoints/", false); uri.AppendPath(managedPrivateEndpointName, 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.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Create or update a managed private endpoint for a grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The managed private endpoint name of Azure Managed Grafana. - /// The managed private endpoint to be created or updated. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task CreateAsync(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, ManagedPrivateEndpointModelData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, workspaceName, managedPrivateEndpointName, 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); - } - } - - /// Create or update a managed private endpoint for a grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The managed private endpoint name of Azure Managed Grafana. - /// The managed private endpoint to be created or updated. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Create(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, ManagedPrivateEndpointModelData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, workspaceName, managedPrivateEndpointName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, ManagedPrivateEndpointModelPatch patch) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/managedPrivateEndpoints/", false); - uri.AppendPath(managedPrivateEndpointName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, ManagedPrivateEndpointModelPatch patch) + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -272,96 +98,19 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath("/managedPrivateEndpoints/", false); uri.AppendPath(managedPrivateEndpointName, 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.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Update a managed private endpoint for an existing grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The managed private endpoint name of Azure Managed Grafana. - /// Properties that can be updated to an existing managed private endpoint. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, ManagedPrivateEndpointModelPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, workspaceName, managedPrivateEndpointName, 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 a managed private endpoint for an existing grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The managed private endpoint name of Azure Managed Grafana. - /// Properties that can be updated to an existing managed private endpoint. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Update(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, ManagedPrivateEndpointModelPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, workspaceName, managedPrivateEndpointName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 202: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, RequestContext context) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/managedPrivateEndpoints/", false); - uri.AppendPath(managedPrivateEndpointName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -372,88 +121,16 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/managedPrivateEndpoints/", false); uri.AppendPath(managedPrivateEndpointName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete a managed private endpoint for a grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The managed private endpoint name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, workspaceName, managedPrivateEndpointName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a managed private endpoint for a grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The managed private endpoint name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Delete(string subscriptionId, string resourceGroupName, string workspaceName, string managedPrivateEndpointName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(managedPrivateEndpointName, nameof(managedPrivateEndpointName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, workspaceName, managedPrivateEndpointName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string workspaceName) + internal HttpMessage CreateGetAllRequest(string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/managedPrivateEndpoints", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string workspaceName) - { - 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -463,152 +140,24 @@ internal HttpMessage CreateListRequest(string subscriptionId, string resourceGro uri.AppendPath(workspaceName, true); uri.AppendPath("/managedPrivateEndpoints", 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.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// List all managed private endpoints of a grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListAsync(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, workspaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedPrivateEndpointModelListResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedPrivateEndpointModelListResponse.DeserializeManagedPrivateEndpointModelListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all managed private endpoints of a grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response List(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, workspaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedPrivateEndpointModelListResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedPrivateEndpointModelListResponse.DeserializeManagedPrivateEndpointModelListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName) + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, string subscriptionId, string resourceGroupName, string workspaceName, 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; } - - /// List all managed private endpoints of a grafana resource. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, workspaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedPrivateEndpointModelListResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ManagedPrivateEndpointModelListResponse.DeserializeManagedPrivateEndpointModelListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all managed private endpoints of a grafana resource. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, workspaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedPrivateEndpointModelListResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ManagedPrivateEndpointModelListResponse.DeserializeManagedPrivateEndpointModelListResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs index cb7df437ade2..4f51118c49b4 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs @@ -6,143 +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.Grafana.Models; namespace Azure.ResourceManager.Grafana { - internal partial class PrivateEndpointConnectionsRestOperations + internal partial class PrivateEndpointConnections { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of PrivateEndpointConnectionsRestOperations. - /// 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 PrivateEndpointConnectionsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of PrivateEndpointConnections for mocking. + protected PrivateEndpointConnections() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-08-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName) + /// Initializes a new instance of PrivateEndpointConnections. + /// 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 PrivateEndpointConnections(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("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/privateEndpointConnections/", false); - uri.AppendPath(privateEndpointConnectionName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/privateEndpointConnections/", false); - uri.AppendPath(privateEndpointConnectionName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Get private endpoint connections. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The private endpoint connection name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, workspaceName, privateEndpointConnectionName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - GrafanaPrivateEndpointConnectionData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = GrafanaPrivateEndpointConnectionData.DeserializeGrafanaPrivateEndpointConnectionData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((GrafanaPrivateEndpointConnectionData)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 private endpoint connections. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The private endpoint connection name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, workspaceName, privateEndpointConnectionName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - GrafanaPrivateEndpointConnectionData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = GrafanaPrivateEndpointConnectionData.DeserializeGrafanaPrivateEndpointConnectionData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((GrafanaPrivateEndpointConnectionData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateApproveRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName, GrafanaPrivateEndpointConnectionData data) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -153,15 +54,17 @@ internal RequestUriBuilder CreateApproveRequestUri(string subscriptionId, string uri.AppendPath("/privateEndpointConnections/", false); uri.AppendPath(privateEndpointConnectionName, 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 CreateApproveRequest(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName, GrafanaPrivateEndpointConnectionData data) + internal HttpMessage CreateApproveRequest(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName, 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -172,94 +75,22 @@ internal HttpMessage CreateApproveRequest(string subscriptionId, string resource uri.AppendPath("/privateEndpointConnections/", false); uri.AppendPath(privateEndpointConnectionName, 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; - } - - /// Manual approve private endpoint connection. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The private endpoint connection name of Azure Managed Grafana. - /// The to use. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task ApproveAsync(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName, GrafanaPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateApproveRequest(subscriptionId, resourceGroupName, workspaceName, privateEndpointConnectionName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Manual approve private endpoint connection. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The private endpoint connection name of Azure Managed Grafana. - /// The to use. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Approve(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName, GrafanaPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateApproveRequest(subscriptionId, resourceGroupName, workspaceName, privateEndpointConnectionName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) + request.Method = RequestMethod.Put; + if ("application/json" != null) { - 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 CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/privateEndpointConnections/", false); - uri.AppendPath(privateEndpointConnectionName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -270,86 +101,16 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/privateEndpointConnections/", false); uri.AppendPath(privateEndpointConnectionName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete private endpoint connection. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The private endpoint connection name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, workspaceName, privateEndpointConnectionName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete private endpoint connection. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The private endpoint connection name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Delete(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, workspaceName, privateEndpointConnectionName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string workspaceName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/privateEndpointConnections", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string workspaceName) + internal HttpMessage CreateGetAllRequest(string subscriptionId, string resourceGroupName, string workspaceName, 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -359,152 +120,24 @@ internal HttpMessage CreateListRequest(string subscriptionId, string resourceGro uri.AppendPath(workspaceName, true); uri.AppendPath("/privateEndpointConnections", 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.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Get private endpoint connection. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListAsync(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, workspaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - GrafanaPrivateEndpointConnectionListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = GrafanaPrivateEndpointConnectionListResult.DeserializeGrafanaPrivateEndpointConnectionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Get private endpoint connection. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response List(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, workspaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - GrafanaPrivateEndpointConnectionListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = GrafanaPrivateEndpointConnectionListResult.DeserializeGrafanaPrivateEndpointConnectionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName) + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, string subscriptionId, string resourceGroupName, string workspaceName, 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; } - - /// Get private endpoint connection. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, workspaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - GrafanaPrivateEndpointConnectionListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = GrafanaPrivateEndpointConnectionListResult.DeserializeGrafanaPrivateEndpointConnectionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Get private endpoint connection. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, workspaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - GrafanaPrivateEndpointConnectionListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = GrafanaPrivateEndpointConnectionListResult.DeserializeGrafanaPrivateEndpointConnectionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs index 7238c11d23a5..3526965ec32a 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs @@ -6,58 +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.Grafana.Models; namespace Azure.ResourceManager.Grafana { - internal partial class PrivateLinkResourcesRestOperations + internal partial class PrivateLinkResources { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of PrivateLinkResourcesRestOperations. - /// 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 PrivateLinkResourcesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of PrivateLinkResources for mocking. + protected PrivateLinkResources() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-08-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string workspaceName, string privateLinkResourceName) + /// Initializes a new instance of PrivateLinkResources. + /// 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 PrivateLinkResources(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("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/privateLinkResources/", false); - uri.AppendPath(privateLinkResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string workspaceName, string privateLinkResourceName) + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string workspaceName, string privateLinkResourceName, 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -68,99 +54,17 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGrou uri.AppendPath("/privateLinkResources/", false); uri.AppendPath(privateLinkResourceName, 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; } - /// Get specific private link resource information for this grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The to use. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string workspaceName, string privateLinkResourceName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetAllRequest(string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, workspaceName, privateLinkResourceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - GrafanaPrivateLinkResourceData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = GrafanaPrivateLinkResourceData.DeserializeGrafanaPrivateLinkResourceData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((GrafanaPrivateLinkResourceData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Get specific private link resource information for this grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The to use. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string workspaceName, string privateLinkResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, workspaceName, privateLinkResourceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - GrafanaPrivateLinkResourceData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = GrafanaPrivateLinkResourceData.DeserializeGrafanaPrivateLinkResourceData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((GrafanaPrivateLinkResourceData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string workspaceName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Dashboard/grafana/", false); - uri.AppendPath(workspaceName, true); - uri.AppendPath("/privateLinkResources", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string workspaceName) - { - 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("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -170,152 +74,24 @@ internal HttpMessage CreateListRequest(string subscriptionId, string resourceGro uri.AppendPath(workspaceName, true); uri.AppendPath("/privateLinkResources", 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.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// List all private link resources information for this grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListAsync(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, workspaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - GrafanaPrivateLinkResourceListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = GrafanaPrivateLinkResourceListResult.DeserializeGrafanaPrivateLinkResourceListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all private link resources information for this grafana resource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response List(string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, workspaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - GrafanaPrivateLinkResourceListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = GrafanaPrivateLinkResourceListResult.DeserializeGrafanaPrivateLinkResourceListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName) + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, string subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName) - { - 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; } - - /// List all private link resources information for this grafana resource. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, workspaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - GrafanaPrivateLinkResourceListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = GrafanaPrivateLinkResourceListResult.DeserializeGrafanaPrivateLinkResourceListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all private link resources information for this grafana resource. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The workspace name of Azure Managed Grafana. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string workspaceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, workspaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - GrafanaPrivateLinkResourceListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = GrafanaPrivateLinkResourceListResult.DeserializeGrafanaPrivateLinkResourceListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/tsp-location.yaml b/sdk/grafana/Azure.ResourceManager.Grafana/tsp-location.yaml index c7c427d0bc70..ba7d07c05082 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/tsp-location.yaml +++ b/sdk/grafana/Azure.ResourceManager.Grafana/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/dashboard/Dashboard.Management -commit: a39b73b1c7d12a633805a3b2ed3177a8bfddd9e2 +commit: 5ef7e9410d6280259dd419bc7d646de1a5d1bbfa repo: Azure/azure-rest-api-specs -additionalDirectories: +emitterPackageJsonPath: "eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json"