diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/Azure.ResourceManager.Monitor.Workspaces.slnx b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/Azure.ResourceManager.Monitor.Workspaces.slnx new file mode 100644 index 000000000000..2b2821c6ab3e --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/Azure.ResourceManager.Monitor.Workspaces.slnx @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/CHANGELOG.md b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes \ No newline at end of file diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/Directory.Build.props b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/Directory.Build.props new file mode 100644 index 000000000000..5586456deee8 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/Directory.Build.props @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/README.md b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/README.md new file mode 100644 index 000000000000..2f48abd13032 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/README.md @@ -0,0 +1,80 @@ +# Azure.ResourceManager.Monitor.Workspaces management client library for .NET + +This library supports managing Microsoft Azure resources. + +This library follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +## Getting started + +### Install the package + +Install the Azure.ResourceManager.Monitor.Workspaces management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.Monitor.Workspaces --prerelease +``` + +### Prerequisites + +* You must have a [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html). + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://learn.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/metadata.json b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/metadata.json new file mode 100644 index 000000000000..9291041c969e --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/metadata.json @@ -0,0 +1,5 @@ +{ + "apiVersions": { + "Microsoft.Monitor": "2025-10-03" + } +} \ No newline at end of file diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Azure.ResourceManager.Monitor.Workspaces.csproj b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Azure.ResourceManager.Monitor.Workspaces.csproj new file mode 100644 index 000000000000..53c6532ec4c4 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Azure.ResourceManager.Monitor.Workspaces.csproj @@ -0,0 +1,9 @@ + + + This is the Azure.ResourceManager.Monitor.Workspaces client library for developing .NET applications with rich experience. + SDK Code Generation Azure.ResourceManager.Monitor.Workspaces + 1.0.0-beta.1 + Azure.ResourceManager.Monitor.Workspaces + true + + diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/ArmMonitorWorkspacesModelFactory.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/ArmMonitorWorkspacesModelFactory.cs new file mode 100644 index 000000000000..6edb607d676a --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/ArmMonitorWorkspacesModelFactory.cs @@ -0,0 +1,346 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// A factory class for creating instances of the models for mocking. + public static partial class ArmMonitorWorkspacesModelFactory + { + + /// An Azure Monitor Workspace definition. + /// 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. + /// Resource properties. + /// The managed service identities assigned to this resource. + /// "If etag is provided in the response body, it may also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields."). + /// A new instance for mocking. + public static AzureMonitorWorkspaceResourceData AzureMonitorWorkspaceResourceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, AzureMonitorWorkspace properties = default, ManagedServiceIdentity identity = default, string eTag = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new AzureMonitorWorkspaceResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties, + identity, + eTag); + } + + /// Properties of an Azure Monitor Workspace. + /// The immutable Id of the Azure Monitor Workspace. This property is read-only. + /// Properties related to the metrics container in the Azure Monitor Workspace. + /// The provisioning state of the Azure Monitor Workspace. Set to Succeeded if everything is healthy. + /// The Data Collection Rule and Endpoint used for ingestion by default. + /// List of private endpoint connections. + /// Gets or sets allow or disallow public network access to Azure Monitor Workspace. + /// A new instance for mocking. + public static AzureMonitorWorkspace AzureMonitorWorkspace(string accountId = default, AzureMonitorWorkspaceMetrics metrics = default, ResourceProvisioningState? provisioningState = default, AzureMonitorWorkspaceDefaultIngestionSettings defaultIngestionSettings = default, IEnumerable privateEndpointConnections = default, PublicNetworkAccess? publicNetworkAccess = default) + { + privateEndpointConnections ??= new ChangeTrackingList(); + + return new AzureMonitorWorkspace( + accountId, + metrics, + provisioningState, + defaultIngestionSettings, + privateEndpointConnections.ToList(), + publicNetworkAccess, + additionalBinaryDataProperties: null); + } + + /// Properties related to the metrics container in the Azure Monitor Workspace. + /// The Prometheus query endpoint for the Azure Monitor Workspace. + /// An internal identifier for the metrics container. Only to be used by the system. + /// Flag that indicates whether to enable access using resource permissions. + /// A new instance for mocking. + public static AzureMonitorWorkspaceMetrics AzureMonitorWorkspaceMetrics(string prometheusQueryEndpoint = default, string internalId = default, bool? enableAccessUsingResourcePermissions = default) + { + return new AzureMonitorWorkspaceMetrics(prometheusQueryEndpoint, internalId, enableAccessUsingResourcePermissions, additionalBinaryDataProperties: null); + } + + /// The Azure resource Id of the default data collection rule for this Azure Monitor Workspace. + /// The Azure resource Id of the default data collection endpoint for this Azure Monitor Workspace. + /// The immutable Id of the default data collection rule for this Azure Monitor Workspace. + /// The metrics ingestion endpoint for this Azure Monitor Workspace. + /// A new instance for mocking. + public static AzureMonitorWorkspaceDefaultIngestionSettings AzureMonitorWorkspaceDefaultIngestionSettings(string dataCollectionRuleResourceId = default, string dataCollectionEndpointResourceId = default, string dataCollectionRuleImmutableId = default, string ingestionEndpointsMetrics = default) + { + return new AzureMonitorWorkspaceDefaultIngestionSettings(dataCollectionRuleResourceId, dataCollectionEndpointResourceId, dataCollectionRuleImmutableId, ingestionEndpointsMetrics is null ? default : new IngestionEndpoints(ingestionEndpointsMetrics, null), additionalBinaryDataProperties: null); + } + + /// The private endpoint connection resource. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// The private endpoint connection properties. + /// A new instance for mocking. + public static MonitorWorkspacesPrivateEndpointConnection MonitorWorkspacesPrivateEndpointConnection(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, PrivateEndpointConnectionProperties properties = default) + { + return new MonitorWorkspacesPrivateEndpointConnection( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// The group ids for the private endpoint resource. + /// The resource identifier of the private endpoint. + /// A collection of information about the state of the connection between service consumer and provider. + /// The provisioning state of the private endpoint connection resource. + /// A new instance for mocking. + public static PrivateEndpointConnectionProperties PrivateEndpointConnectionProperties(IEnumerable groupIds = default, ResourceIdentifier privateEndpointId = default, MonitorWorkspacesPrivateLinkServiceConnectionState privateLinkServiceConnectionState = default, MonitorWorkspacesPrivateEndpointConnectionProvisioningState? provisioningState = default) + { + groupIds ??= new ChangeTrackingList(); + + return new PrivateEndpointConnectionProperties(groupIds.ToList(), privateEndpointId is null ? default : new PrivateEndpoint(privateEndpointId, null), privateLinkServiceConnectionState, provisioningState, additionalBinaryDataProperties: null); + } + + /// A collection of information about the state of the connection between service consumer and provider. + /// 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. + /// A new instance for mocking. + public static MonitorWorkspacesPrivateLinkServiceConnectionState MonitorWorkspacesPrivateLinkServiceConnectionState(MonitorWorkspacesPrivateEndpointServiceConnectionStatus? status = default, string description = default, string actionsRequired = default) + { + return new MonitorWorkspacesPrivateLinkServiceConnectionState(status, description, actionsRequired, additionalBinaryDataProperties: null); + } + + /// The type used for updating an Azure Monitor Workspace. + /// Resource tags. + /// The managed service identities assigned to this resource. + /// Resource properties. + /// A new instance for mocking. + public static AzureMonitorWorkspaceResourcePatch AzureMonitorWorkspaceResourcePatch(IDictionary tags = default, ManagedServiceIdentity identity = default, AzureMonitorWorkspace properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new AzureMonitorWorkspaceResourcePatch(tags, identity, properties, additionalBinaryDataProperties: null); + } + + /// The Issue resource. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static IssueResourceData IssueResourceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IssueProperties properties = default) + { + return new IssueResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// The issue properties. + /// The issue title. + /// The issue status. + /// The issue severity. + /// The list of investigations in the issue. + /// The issue impact time (in UTC). + /// The number of investigations in the issue. + /// The issue background information. + /// The issue notification settings. + /// The provisioning state of the resource. + /// A new instance for mocking. + public static IssueProperties IssueProperties(string title = default, Status status = default, string severity = default, IEnumerable investigations = default, DateTimeOffset impactOn = default, int investigationsCount = default, Background background = default, Notifications notifications = default, ResourceProvisioningState? provisioningState = default) + { + investigations ??= new ChangeTrackingList(); + + return new IssueProperties( + title, + status, + severity, + investigations.ToList(), + impactOn, + investigationsCount, + background, + notifications, + provisioningState, + additionalBinaryDataProperties: null); + } + + /// Properties of the current investigation. + /// The unique identifier of the investigation. + /// The creation time of the investigation (in UTC). + /// A new instance for mocking. + public static InvestigationMetadata InvestigationMetadata(Guid id = default, DateTimeOffset createdOn = default) + { + return new InvestigationMetadata(id, createdOn, additionalBinaryDataProperties: null); + } + + /// The issue background information. + /// The background type. + /// The background text. + /// The background details. + /// A new instance for mocking. + public static Background Background(string @type = default, string text = default, IEnumerable details = default) + { + details ??= new ChangeTrackingList(); + + return new Background(@type, text, details.ToList(), additionalBinaryDataProperties: null); + } + + /// Issue notification settings. + /// The types of updates that trigger notifications. + /// The action group IDs to notify. + /// Whether to exclude default action groups from notifications. + /// A new instance for mocking. + public static Notifications Notifications(IEnumerable updateTypes = default, IEnumerable actionGroupIds = default, bool? excludeDefaultActionGroups = default) + { + updateTypes ??= new ChangeTrackingList(); + actionGroupIds ??= new ChangeTrackingList(); + + return new Notifications(updateTypes.ToList(), actionGroupIds.ToList(), excludeDefaultActionGroups, additionalBinaryDataProperties: null); + } + + /// Parameters provided to get the investigation result. + /// The unique identifier of the investigation. + /// A new instance for mocking. + public static FetchInvestigationResultParameters FetchInvestigationResultParameters(Guid investigationId = default) + { + return new FetchInvestigationResultParameters(investigationId, additionalBinaryDataProperties: null); + } + + /// Paged collection of RelatedAlert items. + /// The RelatedAlert items on this page. + /// The link to the next page of items. + /// A new instance for mocking. + public static PagedRelatedAlert PagedRelatedAlert(IEnumerable value = default, Uri nextLink = default) + { + value ??= new ChangeTrackingList(); + + return new PagedRelatedAlert(value.ToList(), nextLink, additionalBinaryDataProperties: null); + } + + /// Properties of an alert which is related to the issue. + /// The alert ID. + /// The alerts's relevance status. + /// The source that related the alert to the issue. + /// The time this relation was added to the issue (in UTC). + /// The last update time of this relation (in UTC). + /// A new instance for mocking. + public static RelatedAlert RelatedAlert(ResourceIdentifier id = default, Relevance relevance = default, Models.Origin origin = default, DateTimeOffset addedOn = default, DateTimeOffset lastModifiedOn = default) + { + return new RelatedAlert( + id, + relevance, + origin, + addedOn, + lastModifiedOn, + additionalBinaryDataProperties: null); + } + + /// A list of related alerts. + /// A list of related alerts. + /// A new instance for mocking. + public static RelatedAlerts RelatedAlerts(IEnumerable value = default) + { + value ??= new ChangeTrackingList(); + + return new RelatedAlerts(value.ToList(), additionalBinaryDataProperties: null); + } + + /// Paged collection of RelatedResource items. + /// The RelatedResource items on this page. + /// The link to the next page of items. + /// A new instance for mocking. + public static PagedRelatedResource PagedRelatedResource(IEnumerable value = default, Uri nextLink = default) + { + value ??= new ChangeTrackingList(); + + return new PagedRelatedResource(value.ToList(), nextLink, additionalBinaryDataProperties: null); + } + + /// Properties of a resource which is related to the issue. + /// The resource ID. + /// The resource's relevance status. + /// The source that related the resource to the issue. + /// The time this relation was added to the issue (in UTC). + /// The last update time of this relation (in UTC). + /// A new instance for mocking. + public static RelatedResource RelatedResource(ResourceIdentifier id = default, Relevance relevance = default, Models.Origin origin = default, DateTimeOffset addedOn = default, DateTimeOffset lastModifiedOn = default) + { + return new RelatedResource( + id, + relevance, + origin, + addedOn, + lastModifiedOn, + additionalBinaryDataProperties: null); + } + + /// A list of related resources. + /// A list of related resources. + /// A new instance for mocking. + public static RelatedResources RelatedResources(IEnumerable value = default) + { + value ??= new ChangeTrackingList(); + + return new RelatedResources(value.ToList(), additionalBinaryDataProperties: null); + } + + /// The issue background visualization. + /// The background visualization content, in Adaptive Card format. + /// The background visualization origin. + /// A new instance for mocking. + public static BackgroundVisualization BackgroundVisualization(string visualization = default, Models.Origin origin = default) + { + return new BackgroundVisualization(visualization, origin, additionalBinaryDataProperties: null); + } + + /// Metrics container resource for an Azure Monitor Workspace. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static MetricsContainerResourceData MetricsContainerResourceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, MetricsContainer properties = default) + { + return new MetricsContainerResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// Properties of a metrics container. + /// The provisioning state of the metrics container. + /// The version of Metrics Query Service that this AMW will use for all metric queries. + /// A new instance for mocking. + public static MetricsContainer MetricsContainer(ResourceProvisioningState? provisioningState = default, string version = default) + { + return new MetricsContainer(provisioningState, version, additionalBinaryDataProperties: null); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResource.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResource.Serialization.cs new file mode 100644 index 000000000000..9d7f305166ae --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResource.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.Monitor.Workspaces +{ + /// + public partial class AzureMonitorWorkspaceResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new AzureMonitorWorkspaceResourceData(); + + /// 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. + AzureMonitorWorkspaceResourceData 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, AzureResourceManagerMonitorWorkspacesContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + AzureMonitorWorkspaceResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerMonitorWorkspacesContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResource.cs new file mode 100644 index 000000000000..d222dbd99777 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResource.cs @@ -0,0 +1,734 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Monitor.Workspaces.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + /// + /// A class representing a AzureMonitorWorkspaceResource 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 GetAzureMonitorWorkspaceResources method. + /// + public partial class AzureMonitorWorkspaceResource : ArmResource + { + private readonly ClientDiagnostics _azureMonitorWorkspacesClientDiagnostics; + private readonly AzureMonitorWorkspaces _azureMonitorWorkspacesRestClient; + private readonly AzureMonitorWorkspaceResourceData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Monitor/accounts"; + + /// Initializes a new instance of AzureMonitorWorkspaceResource for mocking. + protected AzureMonitorWorkspaceResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal AzureMonitorWorkspaceResource(ArmClient client, AzureMonitorWorkspaceResourceData 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 AzureMonitorWorkspaceResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string azureMonitorWorkspaceResourceApiVersion); + _azureMonitorWorkspacesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Monitor.Workspaces", ResourceType.Namespace, Diagnostics); + _azureMonitorWorkspacesRestClient = new AzureMonitorWorkspaces(_azureMonitorWorkspacesClientDiagnostics, Pipeline, Endpoint, azureMonitorWorkspaceResourceApiVersion ?? "2025-10-03"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual AzureMonitorWorkspaceResourceData 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 azureMonitorWorkspaceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}"; + 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), nameof(id)); + } + } + + /// + /// Returns the specified Azure Monitor Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the specified Azure Monitor Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates part of an Azure Monitor Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Update. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(AzureMonitorWorkspaceResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, AzureMonitorWorkspaceResourcePatch.ToRequestContent(patch), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates part of an Azure Monitor Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Update. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(AzureMonitorWorkspaceResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, AzureMonitorWorkspaceResourcePatch.ToRequestContent(patch), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an Azure Monitor Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Delete. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// 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 = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + WorkspacesArmOperation operation = new WorkspacesArmOperation(_azureMonitorWorkspacesClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an Azure Monitor Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Delete. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// 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 = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + WorkspacesArmOperation operation = new WorkspacesArmOperation(_azureMonitorWorkspacesClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + return Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AzureMonitorWorkspaceResourceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AzureMonitorWorkspaceResourcePatch patch = new AzureMonitorWorkspaceResourcePatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + return Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AzureMonitorWorkspaceResourceData current = Get(cancellationToken: cancellationToken).Value.Data; + AzureMonitorWorkspaceResourcePatch patch = new AzureMonitorWorkspaceResourcePatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + return Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AzureMonitorWorkspaceResourceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AzureMonitorWorkspaceResourcePatch patch = new AzureMonitorWorkspaceResourcePatch(); + patch.Tags.ReplaceWith(tags); + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + return Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AzureMonitorWorkspaceResourceData current = Get(cancellationToken: cancellationToken).Value.Data; + AzureMonitorWorkspaceResourcePatch patch = new AzureMonitorWorkspaceResourcePatch(); + patch.Tags.ReplaceWith(tags); + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + return Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AzureMonitorWorkspaceResourceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AzureMonitorWorkspaceResourcePatch patch = new AzureMonitorWorkspaceResourcePatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + return Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AzureMonitorWorkspaceResourceData current = Get(cancellationToken: cancellationToken).Value.Data; + AzureMonitorWorkspaceResourcePatch patch = new AzureMonitorWorkspaceResourcePatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a collection of IssueResources in the . + /// An object representing collection of IssueResources and their operations over a IssueResource. + public virtual IssueResourceCollection GetIssueResources() + { + return GetCachedClient(client => new IssueResourceCollection(client, Id)); + } + + /// Get issue properties. + /// The name of the IssueResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetIssueResourceAsync(string issueName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(issueName, nameof(issueName)); + + return await GetIssueResources().GetAsync(issueName, cancellationToken).ConfigureAwait(false); + } + + /// Get issue properties. + /// The name of the IssueResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetIssueResource(string issueName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(issueName, nameof(issueName)); + + return GetIssueResources().Get(issueName, cancellationToken); + } + + /// Gets a collection of MetricsContainerResources in the . + /// An object representing collection of MetricsContainerResources and their operations over a MetricsContainerResource. + public virtual MetricsContainerResourceCollection GetMetricsContainerResources() + { + return GetCachedClient(client => new MetricsContainerResourceCollection(client, Id)); + } + + /// Gets metrics container settings for a monitoring account. + /// The name of the MetricsContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetMetricsContainerResourceAsync(string metricsContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(metricsContainerName, nameof(metricsContainerName)); + + return await GetMetricsContainerResources().GetAsync(metricsContainerName, cancellationToken).ConfigureAwait(false); + } + + /// Gets metrics container settings for a monitoring account. + /// The name of the MetricsContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetMetricsContainerResource(string metricsContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(metricsContainerName, nameof(metricsContainerName)); + + return GetMetricsContainerResources().Get(metricsContainerName, cancellationToken); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResourceCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResourceCollection.cs new file mode 100644 index 000000000000..18b6f939cf64 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResourceCollection.cs @@ -0,0 +1,574 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + /// + /// 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 GetAzureMonitorWorkspaceResources method from an instance of . + /// + public partial class AzureMonitorWorkspaceResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _azureMonitorWorkspacesClientDiagnostics; + private readonly AzureMonitorWorkspaces _azureMonitorWorkspacesRestClient; + + /// Initializes a new instance of AzureMonitorWorkspaceResourceCollection for mocking. + protected AzureMonitorWorkspaceResourceCollection() + { + } + + /// 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 AzureMonitorWorkspaceResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(AzureMonitorWorkspaceResource.ResourceType, out string azureMonitorWorkspaceResourceApiVersion); + _azureMonitorWorkspacesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Monitor.Workspaces", AzureMonitorWorkspaceResource.ResourceType.Namespace, Diagnostics); + _azureMonitorWorkspacesRestClient = new AzureMonitorWorkspaces(_azureMonitorWorkspacesClientDiagnostics, Pipeline, Endpoint, azureMonitorWorkspaceResourceApiVersion ?? "2025-10-03"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + } + } + + /// + /// Creates or updates an Azure Monitor Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// 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 Monitor Workspace. The name is case insensitive. + /// Properties that need to be specified to create a new Azure Monitor Workspace. + /// 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 azureMonitorWorkspaceName, AzureMonitorWorkspaceResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(azureMonitorWorkspaceName, nameof(azureMonitorWorkspaceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, azureMonitorWorkspaceName, AzureMonitorWorkspaceResourceData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + WorkspacesArmOperation operation = new WorkspacesArmOperation(Response.FromValue(new AzureMonitorWorkspaceResource(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; + } + } + + /// + /// Creates or updates an Azure Monitor Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// 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 Monitor Workspace. The name is case insensitive. + /// Properties that need to be specified to create a new Azure Monitor Workspace. + /// 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 azureMonitorWorkspaceName, AzureMonitorWorkspaceResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(azureMonitorWorkspaceName, nameof(azureMonitorWorkspaceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, azureMonitorWorkspaceName, AzureMonitorWorkspaceResourceData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + WorkspacesArmOperation operation = new WorkspacesArmOperation(Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the specified Azure Monitor Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the Azure Monitor Workspace. The name is case insensitive. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string azureMonitorWorkspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(azureMonitorWorkspaceName, nameof(azureMonitorWorkspaceName)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, azureMonitorWorkspaceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the specified Azure Monitor Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the Azure Monitor Workspace. The name is case insensitive. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string azureMonitorWorkspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(azureMonitorWorkspaceName, nameof(azureMonitorWorkspaceName)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, azureMonitorWorkspaceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists all Azure Monitor Workspaces in the specified resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// 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 AzureMonitorWorkspacesGetByResourceGroupAsyncCollectionResultOfT(_azureMonitorWorkspacesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context, "AzureMonitorWorkspaceResourceCollection.GetAll"), data => new AzureMonitorWorkspaceResource(Client, data)); + } + + /// + /// Lists all Azure Monitor Workspaces in the specified resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// 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 AzureMonitorWorkspacesGetByResourceGroupCollectionResultOfT(_azureMonitorWorkspacesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context, "AzureMonitorWorkspaceResourceCollection.GetAll"), data => new AzureMonitorWorkspaceResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the Azure Monitor Workspace. The name is case insensitive. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string azureMonitorWorkspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(azureMonitorWorkspaceName, nameof(azureMonitorWorkspaceName)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, azureMonitorWorkspaceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AzureMonitorWorkspaceResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the Azure Monitor Workspace. The name is case insensitive. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string azureMonitorWorkspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(azureMonitorWorkspaceName, nameof(azureMonitorWorkspaceName)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, azureMonitorWorkspaceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AzureMonitorWorkspaceResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the Azure Monitor Workspace. The name is case insensitive. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string azureMonitorWorkspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(azureMonitorWorkspaceName, nameof(azureMonitorWorkspaceName)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, azureMonitorWorkspaceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AzureMonitorWorkspaceResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new AzureMonitorWorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the Azure Monitor Workspace. The name is case insensitive. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string azureMonitorWorkspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(azureMonitorWorkspaceName, nameof(azureMonitorWorkspaceName)); + + using DiagnosticScope scope = _azureMonitorWorkspacesClientDiagnostics.CreateScope("AzureMonitorWorkspaceResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _azureMonitorWorkspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, azureMonitorWorkspaceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AzureMonitorWorkspaceResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AzureMonitorWorkspaceResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new AzureMonitorWorkspaceResource(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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResourceData.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResourceData.Serialization.cs new file mode 100644 index 000000000000..9776d5d1b51e --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResourceData.Serialization.cs @@ -0,0 +1,257 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + /// An Azure Monitor Workspace definition. + public partial class AzureMonitorWorkspaceResourceData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureMonitorWorkspaceResourceData() + { + } + + /// 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 DeserializeAzureMonitorWorkspaceResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceResourceData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AzureMonitorWorkspaceResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AzureMonitorWorkspaceResourceData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(AzureMonitorWorkspaceResourceData azureMonitorWorkspaceResourceData) + { + if (azureMonitorWorkspaceResourceData == null) + { + return null; + } + return RequestContent.Create(azureMonitorWorkspaceResourceData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static AzureMonitorWorkspaceResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureMonitorWorkspaceResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceResourceData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + ((IJsonModel)Identity).Write(writer, options.Format == "W" ? ModelSerializationExtensions.WireV3Options : ModelSerializationExtensions.JsonV3Options); + } + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("etag"u8); + writer.WriteStringValue(ETag); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureMonitorWorkspaceResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AzureMonitorWorkspaceResourceData)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(AzureMonitorWorkspaceResourceData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureMonitorWorkspaceResourceData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureMonitorWorkspaceResourceData DeserializeAzureMonitorWorkspaceResourceData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + AzureMonitorWorkspace properties = default; + ManagedServiceIdentity identity = default; + string eTag = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerMonitorWorkspacesContext.Default); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = AzureMonitorWorkspace.DeserializeAzureMonitorWorkspace(prop.Value, options); + continue; + } + if (prop.NameEquals("identity"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), options.Format == "W" ? ModelSerializationExtensions.WireV3Options : ModelSerializationExtensions.JsonV3Options, AzureResourceManagerMonitorWorkspacesContext.Default); + continue; + } + if (prop.NameEquals("etag"u8)) + { + eTag = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureMonitorWorkspaceResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + identity, + eTag); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResourceData.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResourceData.cs new file mode 100644 index 000000000000..af5ce97bf523 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/AzureMonitorWorkspaceResourceData.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + /// An Azure Monitor Workspace definition. + public partial class AzureMonitorWorkspaceResourceData : TrackedResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The geo-location where the resource lives. + public AzureMonitorWorkspaceResourceData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// Resource properties. + /// The managed service identities assigned to this resource. + /// "If etag is provided in the response body, it may also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields."). + internal AzureMonitorWorkspaceResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, AzureMonitorWorkspace properties, ManagedServiceIdentity identity, string eTag) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + Identity = identity; + ETag = eTag; + } + + /// Resource properties. + public AzureMonitorWorkspace Properties { get; set; } + + /// The managed service identities assigned to this resource. + public ManagedServiceIdentity Identity { get; set; } + + /// "If etag is provided in the response body, it may also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields."). + public string ETag { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/AzureMonitorWorkspacesGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/AzureMonitorWorkspacesGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..40c887ac0d8c --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/AzureMonitorWorkspacesGetByResourceGroupAsyncCollectionResultOfT.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.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal partial class AzureMonitorWorkspacesGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly AzureMonitorWorkspaces _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + private readonly string _diagnosticScope; + + /// Initializes a new instance of AzureMonitorWorkspacesGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AzureMonitorWorkspaces 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. + /// The diagnostic scope name. + public AzureMonitorWorkspacesGetByResourceGroupAsyncCollectionResultOfT(AzureMonitorWorkspaces client, Guid subscriptionId, string resourceGroupName, RequestContext context, string diagnosticScope) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + _diagnosticScope = diagnosticScope; + } + + /// Gets the pages of AzureMonitorWorkspacesGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AzureMonitorWorkspacesGetByResourceGroupAsyncCollectionResultOfT 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; + } + AzureMonitorWorkspaceResourceListResult result = AzureMonitorWorkspaceResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope(_diagnosticScope); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/AzureMonitorWorkspacesGetByResourceGroupCollectionResultOfT.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/AzureMonitorWorkspacesGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..75e5f1ffb535 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/AzureMonitorWorkspacesGetByResourceGroupCollectionResultOfT.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.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal partial class AzureMonitorWorkspacesGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly AzureMonitorWorkspaces _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + private readonly string _diagnosticScope; + + /// Initializes a new instance of AzureMonitorWorkspacesGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AzureMonitorWorkspaces 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. + /// The diagnostic scope name. + public AzureMonitorWorkspacesGetByResourceGroupCollectionResultOfT(AzureMonitorWorkspaces client, Guid subscriptionId, string resourceGroupName, RequestContext context, string diagnosticScope) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + _diagnosticScope = diagnosticScope; + } + + /// Gets the pages of AzureMonitorWorkspacesGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AzureMonitorWorkspacesGetByResourceGroupCollectionResultOfT 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; + } + AzureMonitorWorkspaceResourceListResult result = AzureMonitorWorkspaceResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope(_diagnosticScope); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/AzureMonitorWorkspacesGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/AzureMonitorWorkspacesGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..26e9e935800f --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/AzureMonitorWorkspacesGetBySubscriptionAsyncCollectionResultOfT.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.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal partial class AzureMonitorWorkspacesGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly AzureMonitorWorkspaces _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + private readonly string _diagnosticScope; + + /// Initializes a new instance of AzureMonitorWorkspacesGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AzureMonitorWorkspaces 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. + /// The diagnostic scope name. + public AzureMonitorWorkspacesGetBySubscriptionAsyncCollectionResultOfT(AzureMonitorWorkspaces client, Guid subscriptionId, RequestContext context, string diagnosticScope) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + _diagnosticScope = diagnosticScope; + } + + /// Gets the pages of AzureMonitorWorkspacesGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AzureMonitorWorkspacesGetBySubscriptionAsyncCollectionResultOfT 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; + } + AzureMonitorWorkspaceResourceListResult result = AzureMonitorWorkspaceResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope(_diagnosticScope); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/AzureMonitorWorkspacesGetBySubscriptionCollectionResultOfT.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/AzureMonitorWorkspacesGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..e80c985af904 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/AzureMonitorWorkspacesGetBySubscriptionCollectionResultOfT.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.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal partial class AzureMonitorWorkspacesGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly AzureMonitorWorkspaces _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + private readonly string _diagnosticScope; + + /// Initializes a new instance of AzureMonitorWorkspacesGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AzureMonitorWorkspaces 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. + /// The diagnostic scope name. + public AzureMonitorWorkspacesGetBySubscriptionCollectionResultOfT(AzureMonitorWorkspaces client, Guid subscriptionId, RequestContext context, string diagnosticScope) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + _diagnosticScope = diagnosticScope; + } + + /// Gets the pages of AzureMonitorWorkspacesGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AzureMonitorWorkspacesGetBySubscriptionCollectionResultOfT 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; + } + AzureMonitorWorkspaceResourceListResult result = AzureMonitorWorkspaceResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope(_diagnosticScope); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/IssueGetAllAsyncCollectionResultOfT.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/IssueGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..a530155d3ac0 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/IssueGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal partial class IssueGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly Issue _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _azureMonitorWorkspaceName; + private readonly RequestContext _context; + private readonly string _diagnosticScope; + + /// Initializes a new instance of IssueGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Issue 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 Monitor Workspace. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// The diagnostic scope name. + public IssueGetAllAsyncCollectionResultOfT(Issue client, Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, RequestContext context, string diagnosticScope) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _azureMonitorWorkspaceName = azureMonitorWorkspaceName; + _context = context; + _diagnosticScope = diagnosticScope; + } + + /// Gets the pages of IssueGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of IssueGetAllAsyncCollectionResultOfT 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; + } + IssueResourceListResult result = IssueResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _azureMonitorWorkspaceName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _azureMonitorWorkspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope(_diagnosticScope); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/IssueGetAllCollectionResultOfT.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/IssueGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..068fe8932bab --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/IssueGetAllCollectionResultOfT.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal partial class IssueGetAllCollectionResultOfT : Pageable + { + private readonly Issue _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _azureMonitorWorkspaceName; + private readonly RequestContext _context; + private readonly string _diagnosticScope; + + /// Initializes a new instance of IssueGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Issue 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 Monitor Workspace. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// The diagnostic scope name. + public IssueGetAllCollectionResultOfT(Issue client, Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, RequestContext context, string diagnosticScope) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _azureMonitorWorkspaceName = azureMonitorWorkspaceName; + _context = context; + _diagnosticScope = diagnosticScope; + } + + /// Gets the pages of IssueGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of IssueGetAllCollectionResultOfT 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; + } + IssueResourceListResult result = IssueResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _resourceGroupName, _azureMonitorWorkspaceName, _context) : _client.CreateGetAllRequest(_subscriptionId, _resourceGroupName, _azureMonitorWorkspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope(_diagnosticScope); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/MetricsContainersGetByAzureMonitorWorkspaceAsyncCollectionResultOfT.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/MetricsContainersGetByAzureMonitorWorkspaceAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..bbb414913dda --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/MetricsContainersGetByAzureMonitorWorkspaceAsyncCollectionResultOfT.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal partial class MetricsContainersGetByAzureMonitorWorkspaceAsyncCollectionResultOfT : AsyncPageable + { + private readonly MetricsContainers _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _azureMonitorWorkspaceName; + private readonly RequestContext _context; + private readonly string _diagnosticScope; + + /// Initializes a new instance of MetricsContainersGetByAzureMonitorWorkspaceAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The MetricsContainers 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 Monitor Workspace. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// The diagnostic scope name. + public MetricsContainersGetByAzureMonitorWorkspaceAsyncCollectionResultOfT(MetricsContainers client, Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, RequestContext context, string diagnosticScope) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _azureMonitorWorkspaceName = azureMonitorWorkspaceName; + _context = context; + _diagnosticScope = diagnosticScope; + } + + /// Gets the pages of MetricsContainersGetByAzureMonitorWorkspaceAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of MetricsContainersGetByAzureMonitorWorkspaceAsyncCollectionResultOfT 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; + } + MetricsContainerResourceListResult result = MetricsContainerResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByAzureMonitorWorkspaceRequest(nextLink, _subscriptionId, _resourceGroupName, _azureMonitorWorkspaceName, _context) : _client.CreateGetByAzureMonitorWorkspaceRequest(_subscriptionId, _resourceGroupName, _azureMonitorWorkspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope(_diagnosticScope); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/MetricsContainersGetByAzureMonitorWorkspaceCollectionResultOfT.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/MetricsContainersGetByAzureMonitorWorkspaceCollectionResultOfT.cs new file mode 100644 index 000000000000..022455e4b2f5 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/CollectionResults/MetricsContainersGetByAzureMonitorWorkspaceCollectionResultOfT.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal partial class MetricsContainersGetByAzureMonitorWorkspaceCollectionResultOfT : Pageable + { + private readonly MetricsContainers _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _azureMonitorWorkspaceName; + private readonly RequestContext _context; + private readonly string _diagnosticScope; + + /// Initializes a new instance of MetricsContainersGetByAzureMonitorWorkspaceCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The MetricsContainers 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 Monitor Workspace. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// The diagnostic scope name. + public MetricsContainersGetByAzureMonitorWorkspaceCollectionResultOfT(MetricsContainers client, Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, RequestContext context, string diagnosticScope) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _azureMonitorWorkspaceName = azureMonitorWorkspaceName; + _context = context; + _diagnosticScope = diagnosticScope; + } + + /// Gets the pages of MetricsContainersGetByAzureMonitorWorkspaceCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of MetricsContainersGetByAzureMonitorWorkspaceCollectionResultOfT 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; + } + MetricsContainerResourceListResult result = MetricsContainerResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByAzureMonitorWorkspaceRequest(nextLink, _subscriptionId, _resourceGroupName, _azureMonitorWorkspaceName, _context) : _client.CreateGetByAzureMonitorWorkspaceRequest(_subscriptionId, _resourceGroupName, _azureMonitorWorkspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope(_diagnosticScope); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Extensions/MockableMonitorWorkspacesArmClient.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Extensions/MockableMonitorWorkspacesArmClient.cs new file mode 100644 index 000000000000..6c655843cda8 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Extensions/MockableMonitorWorkspacesArmClient.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Mocking +{ + /// A class to add extension methods to . + public partial class MockableMonitorWorkspacesArmClient : ArmResource + { + /// Initializes a new instance of MockableMonitorWorkspacesArmClient for mocking. + protected MockableMonitorWorkspacesArmClient() + { + } + + /// 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 MockableMonitorWorkspacesArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual AzureMonitorWorkspaceResource GetAzureMonitorWorkspaceResource(ResourceIdentifier id) + { + AzureMonitorWorkspaceResource.ValidateResourceId(id); + return new AzureMonitorWorkspaceResource(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 IssueResource GetIssueResource(ResourceIdentifier id) + { + IssueResource.ValidateResourceId(id); + return new IssueResource(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 MetricsContainerResource GetMetricsContainerResource(ResourceIdentifier id) + { + MetricsContainerResource.ValidateResourceId(id); + return new MetricsContainerResource(Client, id); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Extensions/MockableMonitorWorkspacesResourceGroupResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Extensions/MockableMonitorWorkspacesResourceGroupResource.cs new file mode 100644 index 000000000000..89d8a7462246 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Extensions/MockableMonitorWorkspacesResourceGroupResource.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Monitor.Workspaces; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Monitor.Workspaces.Mocking +{ + /// A class to add extension methods to . + public partial class MockableMonitorWorkspacesResourceGroupResource : ArmResource + { + /// Initializes a new instance of MockableMonitorWorkspacesResourceGroupResource for mocking. + protected MockableMonitorWorkspacesResourceGroupResource() + { + } + + /// 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 MockableMonitorWorkspacesResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + /// Gets a collection of AzureMonitorWorkspaceResources in the . + /// An object representing collection of AzureMonitorWorkspaceResources and their operations over a AzureMonitorWorkspaceResource. + public virtual AzureMonitorWorkspaceResourceCollection GetAzureMonitorWorkspaceResources() + { + return GetCachedClient(client => new AzureMonitorWorkspaceResourceCollection(client, Id)); + } + + /// + /// Returns the specified Azure Monitor Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the Azure Monitor Workspace. The name is case insensitive. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetAzureMonitorWorkspaceResourceAsync(string azureMonitorWorkspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(azureMonitorWorkspaceName, nameof(azureMonitorWorkspaceName)); + + return await GetAzureMonitorWorkspaceResources().GetAsync(azureMonitorWorkspaceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns the specified Azure Monitor Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the Azure Monitor Workspace. The name is case insensitive. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetAzureMonitorWorkspaceResource(string azureMonitorWorkspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(azureMonitorWorkspaceName, nameof(azureMonitorWorkspaceName)); + + return GetAzureMonitorWorkspaceResources().Get(azureMonitorWorkspaceName, cancellationToken); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Extensions/MockableMonitorWorkspacesSubscriptionResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Extensions/MockableMonitorWorkspacesSubscriptionResource.cs new file mode 100644 index 000000000000..325dfd6292b8 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Extensions/MockableMonitorWorkspacesSubscriptionResource.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Monitor.Workspaces; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Monitor.Workspaces.Mocking +{ + /// A class to add extension methods to . + public partial class MockableMonitorWorkspacesSubscriptionResource : ArmResource + { + private ClientDiagnostics _azureMonitorWorkspacesClientDiagnostics; + private AzureMonitorWorkspaces _azureMonitorWorkspacesRestClient; + + /// Initializes a new instance of MockableMonitorWorkspacesSubscriptionResource for mocking. + protected MockableMonitorWorkspacesSubscriptionResource() + { + } + + /// 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 MockableMonitorWorkspacesSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics AzureMonitorWorkspacesClientDiagnostics => _azureMonitorWorkspacesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Monitor.Workspaces.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private AzureMonitorWorkspaces AzureMonitorWorkspacesRestClient => _azureMonitorWorkspacesRestClient ??= new AzureMonitorWorkspaces(AzureMonitorWorkspacesClientDiagnostics, Pipeline, Endpoint, "2025-10-03"); + + /// + /// Lists all Azure Monitor Workspaces in the specified subscription + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Monitor/accounts. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAzureMonitorWorkspaceResourcesAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new AzureMonitorWorkspacesGetBySubscriptionAsyncCollectionResultOfT(AzureMonitorWorkspacesRestClient, Guid.Parse(Id.SubscriptionId), context, "MockableMonitorWorkspacesSubscriptionResource.GetAzureMonitorWorkspaceResources"), data => new AzureMonitorWorkspaceResource(Client, data)); + } + + /// + /// Lists all Azure Monitor Workspaces in the specified subscription + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Monitor/accounts. + /// + /// + /// Operation Id. + /// AzureMonitorWorkspaces_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAzureMonitorWorkspaceResources(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new AzureMonitorWorkspacesGetBySubscriptionCollectionResultOfT(AzureMonitorWorkspacesRestClient, Guid.Parse(Id.SubscriptionId), context, "MockableMonitorWorkspacesSubscriptionResource.GetAzureMonitorWorkspaceResources"), data => new AzureMonitorWorkspaceResource(Client, data)); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Extensions/MonitorWorkspacesExtensions.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Extensions/MonitorWorkspacesExtensions.cs new file mode 100644 index 000000000000..7ce05e2f1510 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Extensions/MonitorWorkspacesExtensions.cs @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Monitor.Workspaces.Mocking; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + /// A class to add extension methods to Azure.ResourceManager.Monitor.Workspaces. + public static partial class MonitorWorkspacesExtensions + { + /// + private static MockableMonitorWorkspacesArmClient GetMockableMonitorWorkspacesArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableMonitorWorkspacesArmClient(client0, ResourceIdentifier.Root)); + } + + /// + private static MockableMonitorWorkspacesResourceGroupResource GetMockableMonitorWorkspacesResourceGroupResource(ResourceGroupResource resourceGroupResource) + { + return resourceGroupResource.GetCachedClient(client => new MockableMonitorWorkspacesResourceGroupResource(client, resourceGroupResource.Id)); + } + + /// + private static MockableMonitorWorkspacesSubscriptionResource GetMockableMonitorWorkspacesSubscriptionResource(SubscriptionResource subscriptionResource) + { + return subscriptionResource.GetCachedClient(client => new MockableMonitorWorkspacesSubscriptionResource(client, subscriptionResource.Id)); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static AzureMonitorWorkspaceResource GetAzureMonitorWorkspaceResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableMonitorWorkspacesArmClient(client).GetAzureMonitorWorkspaceResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static IssueResource GetIssueResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableMonitorWorkspacesArmClient(client).GetIssueResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static MetricsContainerResource GetMetricsContainerResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableMonitorWorkspacesArmClient(client).GetMetricsContainerResource(id); + } + + /// + /// Gets a collection of AzureMonitorWorkspaceResources in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of AzureMonitorWorkspaceResources and their operations over a AzureMonitorWorkspaceResource. + public static AzureMonitorWorkspaceResourceCollection GetAzureMonitorWorkspaceResources(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableMonitorWorkspacesResourceGroupResource(resourceGroupResource).GetAzureMonitorWorkspaceResources(); + } + + /// + /// Returns the specified Azure Monitor Workspace + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Azure Monitor Workspace. The name is case insensitive. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetAzureMonitorWorkspaceResourceAsync(this ResourceGroupResource resourceGroupResource, string azureMonitorWorkspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableMonitorWorkspacesResourceGroupResource(resourceGroupResource).GetAzureMonitorWorkspaceResourceAsync(azureMonitorWorkspaceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns the specified Azure Monitor Workspace + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Azure Monitor Workspace. The name is case insensitive. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetAzureMonitorWorkspaceResource(this ResourceGroupResource resourceGroupResource, string azureMonitorWorkspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableMonitorWorkspacesResourceGroupResource(resourceGroupResource).GetAzureMonitorWorkspaceResource(azureMonitorWorkspaceName, cancellationToken); + } + + /// + /// Lists all Azure Monitor Workspaces in the specified subscription + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetAzureMonitorWorkspaceResourcesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableMonitorWorkspacesSubscriptionResource(subscriptionResource).GetAzureMonitorWorkspaceResourcesAsync(cancellationToken); + } + + /// + /// Lists all Azure Monitor Workspaces in the specified subscription + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetAzureMonitorWorkspaceResources(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableMonitorWorkspacesSubscriptionResource(subscriptionResource).GetAzureMonitorWorkspaceResources(cancellationToken); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/Argument.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..93c5bdfe7e74 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/Argument.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal static partial class Argument + { + /// The value. + /// The name. + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + /// The value. + /// The minimum value. + /// The maximum value. + /// The name. + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + /// The value. + /// The name. + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..f8bb88b03778 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/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.Monitor.Workspaces +{ + 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..a841a18cf22b --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerDictionary == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + /// Gets the Keys. + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + /// Gets the Values. + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + /// Gets or sets the value associated with the specified key. + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + /// Gets the Keys. + IEnumerable IReadOnlyDictionary.Keys => Keys; + + /// Gets the Values. + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + /// The item to search for. + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + /// The array to copy. + /// The index. + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + /// The item to remove. + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + /// The key. + /// The value to add. + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + /// The key to search for. + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + /// The key. + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + /// The key to search for. + /// The value. + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/ChangeTrackingList.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..b4db46399a9b --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal partial class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + /// The inner list. + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + /// The inner list. + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerList == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureList().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + /// Gets or sets the value associated with the specified key. + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + /// The item. + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + /// The array to copy to. + /// The array index. + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + /// The item. + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + /// The item. + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + /// The inner list. + /// The item. + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + /// The inner list. + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..2e3ca0d6d6be --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/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.Monitor.Workspaces +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions errorOptions) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (errorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions errorOptions) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (errorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = await pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + + public static Response ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = pipeline.ProcessMessage(message, context); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..72778edeb7e4 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..dfcabf517497 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..38d536e69173 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..f36b5f513173 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/ErrorResult.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..a7115440f119 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/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.Monitor.Workspaces +{ + 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..c7a85e4df626 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,272 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Runtime.InteropServices; +using System.Text.Json; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal static partial class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; + /// The wire v3 options for model serialization. + internal static readonly ModelReaderWriterOptions WireV3Options = new ModelReaderWriterOptions("W|v3"); + /// The JSON v3 options for model serialization. + internal static readonly ModelReaderWriterOptions JsonV3Options = new ModelReaderWriterOptions("J|v3"); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + Dictionary dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + List list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + string text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) + { + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + string value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + public static BinaryData GetUtf8Bytes(this JsonElement element) + { +#if NET9_0_OR_GREATER + return new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(element).ToArray()); +#else + return BinaryData.FromString(element.GetRawText()); +#endif + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/Optional.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..c30dd2f7d63b --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal static partial class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(string value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/PageableWrapper.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..06c837713e1c --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/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.Monitor.Workspaces +{ + 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..ab19d0dd18bf --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal static partial class RawRequestUriBuilderExtensions + { + public static void AppendQueryDelimited(this RawRequestUriBuilder builder, string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + builder.AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + + public static void UpdateQuery(this RawRequestUriBuilder builder, string name, string value) + { + string currentQuery = builder.Query; + string searchPattern = string.Concat(name, "="); + int paramStartIndex = -1; + if (currentQuery.StartsWith(string.Concat("?", searchPattern))) + { + paramStartIndex = 1; + } + if (paramStartIndex == -1) + { + string prefixedPattern = string.Concat("&", searchPattern); + int prefixedIndex = currentQuery.IndexOf(prefixedPattern); + if (prefixedIndex >= 0) + { + paramStartIndex = prefixedIndex + 1; + } + } + if (paramStartIndex >= 0) + { + int valueStartIndex = paramStartIndex + searchPattern.Length; + int valueEndIndex = currentQuery.IndexOf('&', valueStartIndex); + if (valueEndIndex == -1) + { + valueEndIndex = currentQuery.Length; + } + string beforeParam = currentQuery.Substring(0, valueStartIndex); + string afterParam = currentQuery.Substring(valueEndIndex); + string newQuery = string.Concat(beforeParam, value, afterParam); + builder.Query = newQuery; + } + else + { + builder.AppendQuery(name, value, true); + } + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/RequestContextExtensions.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..550d9aab48d5 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/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.Monitor.Workspaces +{ + 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/SerializationFormat.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..eab660ee2623 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/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.Monitor.Workspaces +{ + 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/TypeFormatters.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..ed54085946c8 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/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.Monitor.Workspaces +{ + 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResource.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResource.Serialization.cs new file mode 100644 index 000000000000..93abf44eef5e --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResource.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.Monitor.Workspaces +{ + /// + public partial class IssueResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new IssueResourceData(); + + /// 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. + IssueResourceData 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, AzureResourceManagerMonitorWorkspacesContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + IssueResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerMonitorWorkspacesContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResource.cs new file mode 100644 index 000000000000..ed9459b787ec --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResource.cs @@ -0,0 +1,1211 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + /// + /// A class representing a IssueResource 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 GetIssueResources method. + /// + public partial class IssueResource : ArmResource + { + private readonly ClientDiagnostics _issueClientDiagnostics; + private readonly Issue _issueRestClient; + private readonly IssueResourceData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Monitor/accounts/issues"; + + /// Initializes a new instance of IssueResource for mocking. + protected IssueResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal IssueResource(ArmClient client, IssueResourceData 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 IssueResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string issueResourceApiVersion); + _issueClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Monitor.Workspaces", ResourceType.Namespace, Diagnostics); + _issueRestClient = new Issue(_issueClientDiagnostics, Pipeline, Endpoint, issueResourceApiVersion ?? "2025-10-03"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual IssueResourceData 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 azureMonitorWorkspaceName. + /// The issueName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string issueName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}"; + 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), nameof(id)); + } + } + + /// + /// Get issue properties + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(IssueResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new IssueResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get issue properties + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(IssueResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new IssueResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update an issue + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Update. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(IssueResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, IssueResourcePatch.ToRequestContent(patch), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(IssueResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new IssueResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update an issue + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Update. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(IssueResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, IssueResourcePatch.ToRequestContent(patch), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(IssueResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new IssueResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete an issue + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Delete. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// 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 = _issueClientDiagnostics.CreateScope("IssueResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateDeleteRequest(Guid.Parse(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()); + WorkspacesArmOperation operation = new WorkspacesArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete an issue + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Delete. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// 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 = _issueClientDiagnostics.CreateScope("IssueResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateDeleteRequest(Guid.Parse(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()); + WorkspacesArmOperation operation = new WorkspacesArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Adds investigation result + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/addInvestigationResult. + /// + /// + /// Operation Id. + /// Issue_AddInvestigationResult. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> AddInvestigationResultAsync(InvestigationResult body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.AddInvestigationResult"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateAddInvestigationResultRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, InvestigationResult.ToRequestContent(body), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(InvestigationResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Adds investigation result + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/addInvestigationResult. + /// + /// + /// Operation Id. + /// Issue_AddInvestigationResult. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual Response AddInvestigationResult(InvestigationResult body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.AddInvestigationResult"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateAddInvestigationResultRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, InvestigationResult.ToRequestContent(body), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(InvestigationResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add or update alerts associated with an issue + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/addOrUpdateAlerts. + /// + /// + /// Operation Id. + /// Issue_AddOrUpdateAlerts. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> AddOrUpdateAlertsAsync(RelatedAlerts body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.AddOrUpdateAlerts"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateAddOrUpdateAlertsRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, RelatedAlerts.ToRequestContent(body), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(RelatedAlerts.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add or update alerts associated with an issue + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/addOrUpdateAlerts. + /// + /// + /// Operation Id. + /// Issue_AddOrUpdateAlerts. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual Response AddOrUpdateAlerts(RelatedAlerts body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.AddOrUpdateAlerts"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateAddOrUpdateAlertsRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, RelatedAlerts.ToRequestContent(body), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(RelatedAlerts.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add or update resources associated with an issue + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/addOrUpdateResources. + /// + /// + /// Operation Id. + /// Issue_AddOrUpdateResources. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> AddOrUpdateResourcesAsync(RelatedResources body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.AddOrUpdateResources"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateAddOrUpdateResourcesRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, RelatedResources.ToRequestContent(body), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(RelatedResources.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add or update resources associated with an issue + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/addOrUpdateResources. + /// + /// + /// Operation Id. + /// Issue_AddOrUpdateResources. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual Response AddOrUpdateResources(RelatedResources body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.AddOrUpdateResources"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateAddOrUpdateResourcesRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, RelatedResources.ToRequestContent(body), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(RelatedResources.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Fetch the background visualization of the issue + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/fetchBackgroundVisualization. + /// + /// + /// Operation Id. + /// Issue_FetchBackgroundVisualization. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> FetchBackgroundVisualizationAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.FetchBackgroundVisualization"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateFetchBackgroundVisualizationRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(BackgroundVisualization.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Fetch the background visualization of the issue + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/fetchBackgroundVisualization. + /// + /// + /// Operation Id. + /// Issue_FetchBackgroundVisualization. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response FetchBackgroundVisualization(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.FetchBackgroundVisualization"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateFetchBackgroundVisualizationRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(BackgroundVisualization.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Fetch investigation result + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/fetchInvestigationResult. + /// + /// + /// Operation Id. + /// Issue_FetchInvestigationResult. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> FetchInvestigationResultAsync(FetchInvestigationResultParameters content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.FetchInvestigationResult"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateFetchInvestigationResultRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, FetchInvestigationResultParameters.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(InvestigationResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Fetch investigation result + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/fetchInvestigationResult. + /// + /// + /// Operation Id. + /// Issue_FetchInvestigationResult. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual Response FetchInvestigationResult(FetchInvestigationResultParameters content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.FetchInvestigationResult"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateFetchInvestigationResultRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, FetchInvestigationResultParameters.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(InvestigationResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List all alerts in the issue - this method uses pagination to return all alerts + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/listAlerts. + /// + /// + /// Operation Id. + /// Issue_ListAlerts. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> GetAlertsAsync(ListParameterContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.GetAlerts"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateGetAlertsRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, ListParameterContent.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(PagedRelatedAlert.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List all alerts in the issue - this method uses pagination to return all alerts + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/listAlerts. + /// + /// + /// Operation Id. + /// Issue_ListAlerts. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual Response GetAlerts(ListParameterContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.GetAlerts"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateGetAlertsRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, ListParameterContent.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(PagedRelatedAlert.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List all resources in the issue - this method uses pagination to return all resources + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/listResources. + /// + /// + /// Operation Id. + /// Issue_ListResources. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> GetResourcesAsync(ListParameterContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.GetResources"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateGetResourcesRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, ListParameterContent.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(PagedRelatedResource.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List all resources in the issue - this method uses pagination to return all resources + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/listResources. + /// + /// + /// Operation Id. + /// Issue_ListResources. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual Response GetResources(ListParameterContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.GetResources"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateGetResourcesRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, ListParameterContent.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(PagedRelatedResource.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Set the background visualization for the issue + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/setBackgroundVisualization. + /// + /// + /// Operation Id. + /// Issue_SetBackgroundVisualization. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task SetBackgroundVisualizationAsync(BackgroundVisualization body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.SetBackgroundVisualization"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateSetBackgroundVisualizationRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, BackgroundVisualization.ToRequestContent(body), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Set the background visualization for the issue + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/setBackgroundVisualization. + /// + /// + /// Operation Id. + /// Issue_SetBackgroundVisualization. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual Response SetBackgroundVisualization(BackgroundVisualization body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResource.SetBackgroundVisualization"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateSetBackgroundVisualizationRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, BackgroundVisualization.ToRequestContent(body), context); + Response response = Pipeline.ProcessMessage(message, context); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResourceCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResourceCollection.cs new file mode 100644 index 000000000000..0f4079a01421 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResourceCollection.cs @@ -0,0 +1,587 @@ +// 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.Monitor.Workspaces +{ + /// + /// 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 GetIssueResources method from an instance of . + /// + public partial class IssueResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _issueClientDiagnostics; + private readonly Issue _issueRestClient; + + /// Initializes a new instance of IssueResourceCollection for mocking. + protected IssueResourceCollection() + { + } + + /// 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 IssueResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(IssueResource.ResourceType, out string issueResourceApiVersion); + _issueClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Monitor.Workspaces", IssueResource.ResourceType.Namespace, Diagnostics); + _issueRestClient = new Issue(_issueClientDiagnostics, Pipeline, Endpoint, issueResourceApiVersion ?? "2025-10-03"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != AzureMonitorWorkspaceResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, AzureMonitorWorkspaceResource.ResourceType), nameof(id)); + } + } + + /// + /// Create a new issue or updates an existing one + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Create. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// 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 IssueResource. + /// Resource create parameters. + /// Related resource or alert that is to be added to the issue (default: empty - the issue will be created without any related resources or alerts). + /// 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 issueName, IssueResourceData data, string related = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(issueName, nameof(issueName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, issueName, IssueResourceData.ToRequestContent(data), related, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(IssueResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + WorkspacesArmOperation operation = new WorkspacesArmOperation(Response.FromValue(new IssueResource(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 new issue or updates an existing one + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Create. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// 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 IssueResource. + /// Resource create parameters. + /// Related resource or alert that is to be added to the issue (default: empty - the issue will be created without any related resources or alerts). + /// 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 issueName, IssueResourceData data, string related = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(issueName, nameof(issueName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, issueName, IssueResourceData.ToRequestContent(data), related, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(IssueResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + WorkspacesArmOperation operation = new WorkspacesArmOperation(Response.FromValue(new IssueResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get issue properties + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the IssueResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string issueName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(issueName, nameof(issueName)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, issueName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(IssueResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new IssueResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get issue properties + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the IssueResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string issueName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(issueName, nameof(issueName)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, issueName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(IssueResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new IssueResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List all issues under the parent + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues. + /// + /// + /// Operation Id. + /// Issue_List. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// 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 IssueGetAllAsyncCollectionResultOfT( + _issueRestClient, + Guid.Parse(Id.SubscriptionId), + Id.ResourceGroupName, + Id.Name, + context, + "IssueResourceCollection.GetAll"), data => new IssueResource(Client, data)); + } + + /// + /// List all issues under the parent + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues. + /// + /// + /// Operation Id. + /// Issue_List. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// 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 IssueGetAllCollectionResultOfT( + _issueRestClient, + Guid.Parse(Id.SubscriptionId), + Id.ResourceGroupName, + Id.Name, + context, + "IssueResourceCollection.GetAll"), data => new IssueResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the IssueResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string issueName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(issueName, nameof(issueName)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, issueName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(IssueResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((IssueResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the IssueResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string issueName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(issueName, nameof(issueName)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, issueName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(IssueResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((IssueResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the IssueResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string issueName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(issueName, nameof(issueName)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, issueName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(IssueResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((IssueResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new IssueResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}. + /// + /// + /// Operation Id. + /// Issue_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the IssueResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string issueName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(issueName, nameof(issueName)); + + using DiagnosticScope scope = _issueClientDiagnostics.CreateScope("IssueResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _issueRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, issueName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(IssueResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((IssueResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new IssueResource(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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResourceData.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResourceData.Serialization.cs new file mode 100644 index 000000000000..33e9cf6a4c21 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResourceData.Serialization.cs @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + /// The Issue resource. + public partial class IssueResourceData : ResourceData, IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeIssueResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IssueResourceData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(IssueResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + IssueResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (IssueResourceData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(IssueResourceData issueResourceData) + { + if (issueResourceData == null) + { + return null; + } + return RequestContent.Create(issueResourceData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static IssueResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeIssueResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IssueResourceData)} 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. + IssueResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (IssueResourceData)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(IssueResourceData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIssueResourceData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static IssueResourceData DeserializeIssueResourceData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IssueProperties properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerMonitorWorkspacesContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = IssueProperties.DeserializeIssueProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new IssueResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResourceData.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResourceData.cs new file mode 100644 index 000000000000..7d92a615fc38 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/IssueResourceData.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.Models; +using Azure.ResourceManager.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + /// The Issue resource. + public partial class IssueResourceData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public IssueResourceData() + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// The resource-specific properties for this resource. + internal IssueResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IssueProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public IssueProperties Properties { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/LongRunningOperation/WorkspacesArmOperation.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/LongRunningOperation/WorkspacesArmOperation.cs new file mode 100644 index 000000000000..70f095131a44 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/LongRunningOperation/WorkspacesArmOperation.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal partial class WorkspacesArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of WorkspacesArmOperation for mocking. + protected WorkspacesArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal WorkspacesArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + /// + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. + internal WorkspacesArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) + { + _nextLinkOperation = nextLinkOperationImplementation; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal( + nextLinkOperation, + clientDiagnostics, + response, + "WorkspacesArmOperation", + null, + new SequentialDelayStrategy()); + } + + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); + + /// + public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/LongRunningOperation/WorkspacesArmOperationOfT.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/LongRunningOperation/WorkspacesArmOperationOfT.cs new file mode 100644 index 000000000000..9b110e3ee55c --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/LongRunningOperation/WorkspacesArmOperationOfT.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal partial class WorkspacesArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of WorkspacesArmOperation for mocking. + protected WorkspacesArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal WorkspacesArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + /// + /// The instance of . + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. + internal WorkspacesArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) + { + _nextLinkOperation = nextLinkOperationImplementation; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "WorkspacesArmOperation", + null, + new SequentialDelayStrategy()); + } + + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the Value. + public override T Value => _operation.Value; + + /// Gets the HasValue. + public override bool HasValue => _operation.HasValue; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); + + /// + public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResource.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResource.Serialization.cs new file mode 100644 index 000000000000..0b9617472c44 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResource.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.Monitor.Workspaces +{ + /// + public partial class MetricsContainerResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new MetricsContainerResourceData(); + + /// 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. + MetricsContainerResourceData 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, AzureResourceManagerMonitorWorkspacesContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + MetricsContainerResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerMonitorWorkspacesContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResource.cs new file mode 100644 index 000000000000..f188a3449794 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResource.cs @@ -0,0 +1,302 @@ +// 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.Monitor.Workspaces +{ + /// + /// A class representing a MetricsContainerResource 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 GetMetricsContainerResources method. + /// + public partial class MetricsContainerResource : ArmResource + { + private readonly ClientDiagnostics _metricsContainersClientDiagnostics; + private readonly MetricsContainers _metricsContainersRestClient; + private readonly MetricsContainerResourceData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Monitor/accounts/metricsContainers"; + + /// Initializes a new instance of MetricsContainerResource for mocking. + protected MetricsContainerResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal MetricsContainerResource(ArmClient client, MetricsContainerResourceData 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 MetricsContainerResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string metricsContainerResourceApiVersion); + _metricsContainersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Monitor.Workspaces", ResourceType.Namespace, Diagnostics); + _metricsContainersRestClient = new MetricsContainers(_metricsContainersClientDiagnostics, Pipeline, Endpoint, metricsContainerResourceApiVersion ?? "2025-10-03"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual MetricsContainerResourceData 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 azureMonitorWorkspaceName. + /// The metricsContainerName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string metricsContainerName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}"; + 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), nameof(id)); + } + } + + /// + /// Gets metrics container settings for a monitoring account. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}. + /// + /// + /// Operation Id. + /// MetricsContainers_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _metricsContainersClientDiagnostics.CreateScope("MetricsContainerResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _metricsContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(MetricsContainerResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new MetricsContainerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets metrics container settings for a monitoring account. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}. + /// + /// + /// Operation Id. + /// MetricsContainers_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _metricsContainersClientDiagnostics.CreateScope("MetricsContainerResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _metricsContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(MetricsContainerResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new MetricsContainerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a MetricsContainerResource. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}. + /// + /// + /// Operation Id. + /// MetricsContainers_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// 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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, MetricsContainerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _metricsContainersClientDiagnostics.CreateScope("MetricsContainerResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _metricsContainersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, MetricsContainerResourceData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(MetricsContainerResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + WorkspacesArmOperation operation = new WorkspacesArmOperation(Response.FromValue(new MetricsContainerResource(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; + } + } + + /// + /// Update a MetricsContainerResource. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}. + /// + /// + /// Operation Id. + /// MetricsContainers_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// 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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, MetricsContainerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _metricsContainersClientDiagnostics.CreateScope("MetricsContainerResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _metricsContainersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, MetricsContainerResourceData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(MetricsContainerResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + WorkspacesArmOperation operation = new WorkspacesArmOperation(Response.FromValue(new MetricsContainerResource(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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResourceCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResourceCollection.cs new file mode 100644 index 000000000000..597d3ee03b97 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResourceCollection.cs @@ -0,0 +1,585 @@ +// 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.Monitor.Workspaces +{ + /// + /// 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 GetMetricsContainerResources method from an instance of . + /// + public partial class MetricsContainerResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _metricsContainersClientDiagnostics; + private readonly MetricsContainers _metricsContainersRestClient; + + /// Initializes a new instance of MetricsContainerResourceCollection for mocking. + protected MetricsContainerResourceCollection() + { + } + + /// 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 MetricsContainerResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(MetricsContainerResource.ResourceType, out string metricsContainerResourceApiVersion); + _metricsContainersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Monitor.Workspaces", MetricsContainerResource.ResourceType.Namespace, Diagnostics); + _metricsContainersRestClient = new MetricsContainers(_metricsContainersClientDiagnostics, Pipeline, Endpoint, metricsContainerResourceApiVersion ?? "2025-10-03"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != AzureMonitorWorkspaceResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, AzureMonitorWorkspaceResource.ResourceType), nameof(id)); + } + } + + /// + /// Creates or updates metrics container settings for a monitoring account. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}. + /// + /// + /// Operation Id. + /// MetricsContainers_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// 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 MetricsContainer. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string metricsContainerName, MetricsContainerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(metricsContainerName, nameof(metricsContainerName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _metricsContainersClientDiagnostics.CreateScope("MetricsContainerResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _metricsContainersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, metricsContainerName, MetricsContainerResourceData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(MetricsContainerResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + WorkspacesArmOperation operation = new WorkspacesArmOperation(Response.FromValue(new MetricsContainerResource(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; + } + } + + /// + /// Creates or updates metrics container settings for a monitoring account. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}. + /// + /// + /// Operation Id. + /// MetricsContainers_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// 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 MetricsContainer. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string metricsContainerName, MetricsContainerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(metricsContainerName, nameof(metricsContainerName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _metricsContainersClientDiagnostics.CreateScope("MetricsContainerResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _metricsContainersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, metricsContainerName, MetricsContainerResourceData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(MetricsContainerResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + WorkspacesArmOperation operation = new WorkspacesArmOperation(Response.FromValue(new MetricsContainerResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets metrics container settings for a monitoring account. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}. + /// + /// + /// Operation Id. + /// MetricsContainers_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the MetricsContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string metricsContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(metricsContainerName, nameof(metricsContainerName)); + + using DiagnosticScope scope = _metricsContainersClientDiagnostics.CreateScope("MetricsContainerResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _metricsContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, metricsContainerName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(MetricsContainerResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new MetricsContainerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets metrics container settings for a monitoring account. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}. + /// + /// + /// Operation Id. + /// MetricsContainers_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the MetricsContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string metricsContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(metricsContainerName, nameof(metricsContainerName)); + + using DiagnosticScope scope = _metricsContainersClientDiagnostics.CreateScope("MetricsContainerResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _metricsContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, metricsContainerName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(MetricsContainerResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new MetricsContainerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists metrics containers for a monitoring account. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers. + /// + /// + /// Operation Id. + /// MetricsContainers_ListByAzureMonitorWorkspace. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// 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 MetricsContainersGetByAzureMonitorWorkspaceAsyncCollectionResultOfT( + _metricsContainersRestClient, + Guid.Parse(Id.SubscriptionId), + Id.ResourceGroupName, + Id.Name, + context, + "MetricsContainerResourceCollection.GetAll"), data => new MetricsContainerResource(Client, data)); + } + + /// + /// Lists metrics containers for a monitoring account. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers. + /// + /// + /// Operation Id. + /// MetricsContainers_ListByAzureMonitorWorkspace. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// 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 MetricsContainersGetByAzureMonitorWorkspaceCollectionResultOfT( + _metricsContainersRestClient, + Guid.Parse(Id.SubscriptionId), + Id.ResourceGroupName, + Id.Name, + context, + "MetricsContainerResourceCollection.GetAll"), data => new MetricsContainerResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}. + /// + /// + /// Operation Id. + /// MetricsContainers_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the MetricsContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string metricsContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(metricsContainerName, nameof(metricsContainerName)); + + using DiagnosticScope scope = _metricsContainersClientDiagnostics.CreateScope("MetricsContainerResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _metricsContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, metricsContainerName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(MetricsContainerResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((MetricsContainerResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}. + /// + /// + /// Operation Id. + /// MetricsContainers_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the MetricsContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string metricsContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(metricsContainerName, nameof(metricsContainerName)); + + using DiagnosticScope scope = _metricsContainersClientDiagnostics.CreateScope("MetricsContainerResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _metricsContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, metricsContainerName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(MetricsContainerResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((MetricsContainerResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}. + /// + /// + /// Operation Id. + /// MetricsContainers_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the MetricsContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string metricsContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(metricsContainerName, nameof(metricsContainerName)); + + using DiagnosticScope scope = _metricsContainersClientDiagnostics.CreateScope("MetricsContainerResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _metricsContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, metricsContainerName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(MetricsContainerResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((MetricsContainerResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new MetricsContainerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}. + /// + /// + /// Operation Id. + /// MetricsContainers_Get. + /// + /// + /// Default Api Version. + /// 2025-10-03. + /// + /// + /// + /// The name of the MetricsContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string metricsContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(metricsContainerName, nameof(metricsContainerName)); + + using DiagnosticScope scope = _metricsContainersClientDiagnostics.CreateScope("MetricsContainerResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _metricsContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, metricsContainerName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(MetricsContainerResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((MetricsContainerResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new MetricsContainerResource(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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResourceData.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResourceData.Serialization.cs new file mode 100644 index 000000000000..a0a10a36f440 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResourceData.Serialization.cs @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + /// Metrics container resource for an Azure Monitor Workspace. + public partial class MetricsContainerResourceData : ResourceData, IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMetricsContainerResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricsContainerResourceData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(MetricsContainerResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + MetricsContainerResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MetricsContainerResourceData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(MetricsContainerResourceData metricsContainerResourceData) + { + if (metricsContainerResourceData == null) + { + return null; + } + return RequestContent.Create(metricsContainerResourceData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static MetricsContainerResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetricsContainerResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricsContainerResourceData)} 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. + MetricsContainerResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MetricsContainerResourceData)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(MetricsContainerResourceData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricsContainerResourceData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MetricsContainerResourceData DeserializeMetricsContainerResourceData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + MetricsContainer properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerMonitorWorkspacesContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = MetricsContainer.DeserializeMetricsContainer(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MetricsContainerResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResourceData.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResourceData.cs new file mode 100644 index 000000000000..f9dbe0c9f4fd --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/MetricsContainerResourceData.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.Models; +using Azure.ResourceManager.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + /// Metrics container resource for an Azure Monitor Workspace. + public partial class MetricsContainerResourceData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public MetricsContainerResourceData() + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// The resource-specific properties for this resource. + internal MetricsContainerResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, MetricsContainer properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public MetricsContainer Properties { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AddedByType.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AddedByType.cs new file mode 100644 index 000000000000..416192583ede --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AddedByType.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The type of entity that added data to the issue. + internal readonly partial struct AddedByType : IEquatable + { + private readonly string _value; + /// The data was added manually by a user. + private const string ManualValue = "Manual"; + /// The data was added automatically. + private const string AutomaticValue = "Automatic"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public AddedByType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// The data was added manually by a user. + public static AddedByType Manual { get; } = new AddedByType(ManualValue); + + /// The data was added automatically. + public static AddedByType Automatic { get; } = new AddedByType(AutomaticValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(AddedByType left, AddedByType 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 !=(AddedByType left, AddedByType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator AddedByType(string value) => new AddedByType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator AddedByType?(string value) => value == null ? null : new AddedByType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AddedByType other && Equals(other); + + /// + public bool Equals(AddedByType 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspace.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspace.Serialization.cs new file mode 100644 index 000000000000..1ea5ece2b970 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspace.Serialization.cs @@ -0,0 +1,233 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Properties of an Azure Monitor Workspace. + public partial class AzureMonitorWorkspace : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureMonitorWorkspace 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 DeserializeAzureMonitorWorkspace(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureMonitorWorkspace)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(AzureMonitorWorkspace)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AzureMonitorWorkspace IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureMonitorWorkspace)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(AccountId)) + { + writer.WritePropertyName("accountId"u8); + writer.WriteStringValue(AccountId); + } + if (Optional.IsDefined(Metrics)) + { + writer.WritePropertyName("metrics"u8); + writer.WriteObjectValue(Metrics, options); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(DefaultIngestionSettings)) + { + writer.WritePropertyName("defaultIngestionSettings"u8); + writer.WriteObjectValue(DefaultIngestionSettings, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(PrivateEndpointConnections)) + { + writer.WritePropertyName("privateEndpointConnections"u8); + writer.WriteStartArray(); + foreach (MonitorWorkspacesPrivateEndpointConnection item in PrivateEndpointConnections) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PublicNetworkAccess)) + { + writer.WritePropertyName("publicNetworkAccess"u8); + writer.WriteStringValue(PublicNetworkAccess.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. + AzureMonitorWorkspace IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureMonitorWorkspace 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(AzureMonitorWorkspace)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureMonitorWorkspace(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureMonitorWorkspace DeserializeAzureMonitorWorkspace(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string accountId = default; + AzureMonitorWorkspaceMetrics metrics = default; + ResourceProvisioningState? provisioningState = default; + AzureMonitorWorkspaceDefaultIngestionSettings defaultIngestionSettings = default; + IReadOnlyList privateEndpointConnections = default; + PublicNetworkAccess? publicNetworkAccess = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("accountId"u8)) + { + accountId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("metrics"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + metrics = AzureMonitorWorkspaceMetrics.DeserializeAzureMonitorWorkspaceMetrics(prop.Value, options); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ResourceProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("defaultIngestionSettings"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + defaultIngestionSettings = AzureMonitorWorkspaceDefaultIngestionSettings.DeserializeAzureMonitorWorkspaceDefaultIngestionSettings(prop.Value, options); + continue; + } + if (prop.NameEquals("privateEndpointConnections"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(MonitorWorkspacesPrivateEndpointConnection.DeserializeMonitorWorkspacesPrivateEndpointConnection(item, options)); + } + privateEndpointConnections = array; + continue; + } + if (prop.NameEquals("publicNetworkAccess"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicNetworkAccess = new PublicNetworkAccess(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureMonitorWorkspace( + accountId, + metrics, + provisioningState, + defaultIngestionSettings, + privateEndpointConnections ?? new ChangeTrackingList(), + publicNetworkAccess, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspace.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspace.cs new file mode 100644 index 000000000000..7f43c31d7f2b --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspace.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Properties of an Azure Monitor Workspace. + public partial class AzureMonitorWorkspace + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AzureMonitorWorkspace() + { + PrivateEndpointConnections = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The immutable Id of the Azure Monitor Workspace. This property is read-only. + /// Properties related to the metrics container in the Azure Monitor Workspace. + /// The provisioning state of the Azure Monitor Workspace. Set to Succeeded if everything is healthy. + /// The Data Collection Rule and Endpoint used for ingestion by default. + /// List of private endpoint connections. + /// Gets or sets allow or disallow public network access to Azure Monitor Workspace. + /// Keeps track of any properties unknown to the library. + internal AzureMonitorWorkspace(string accountId, AzureMonitorWorkspaceMetrics metrics, ResourceProvisioningState? provisioningState, AzureMonitorWorkspaceDefaultIngestionSettings defaultIngestionSettings, IReadOnlyList privateEndpointConnections, PublicNetworkAccess? publicNetworkAccess, IDictionary additionalBinaryDataProperties) + { + AccountId = accountId; + Metrics = metrics; + ProvisioningState = provisioningState; + DefaultIngestionSettings = defaultIngestionSettings; + PrivateEndpointConnections = privateEndpointConnections; + PublicNetworkAccess = publicNetworkAccess; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The immutable Id of the Azure Monitor Workspace. This property is read-only. + public string AccountId { get; } + + /// Properties related to the metrics container in the Azure Monitor Workspace. + public AzureMonitorWorkspaceMetrics Metrics { get; set; } + + /// The provisioning state of the Azure Monitor Workspace. Set to Succeeded if everything is healthy. + public ResourceProvisioningState? ProvisioningState { get; } + + /// The Data Collection Rule and Endpoint used for ingestion by default. + public AzureMonitorWorkspaceDefaultIngestionSettings DefaultIngestionSettings { get; } + + /// List of private endpoint connections. + public IReadOnlyList PrivateEndpointConnections { get; } + + /// Gets or sets allow or disallow public network access to Azure Monitor Workspace. + public PublicNetworkAccess? PublicNetworkAccess { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceDefaultIngestionSettings.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceDefaultIngestionSettings.Serialization.cs new file mode 100644 index 000000000000..88a1252a67f5 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceDefaultIngestionSettings.Serialization.cs @@ -0,0 +1,178 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The Data Collection Rule and Endpoint used for ingestion by default. + public partial class AzureMonitorWorkspaceDefaultIngestionSettings : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureMonitorWorkspaceDefaultIngestionSettings 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 DeserializeAzureMonitorWorkspaceDefaultIngestionSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceDefaultIngestionSettings)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceDefaultIngestionSettings)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AzureMonitorWorkspaceDefaultIngestionSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceDefaultIngestionSettings)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(DataCollectionRuleResourceId)) + { + writer.WritePropertyName("dataCollectionRuleResourceId"u8); + writer.WriteStringValue(DataCollectionRuleResourceId); + } + if (options.Format != "W" && Optional.IsDefined(DataCollectionEndpointResourceId)) + { + writer.WritePropertyName("dataCollectionEndpointResourceId"u8); + writer.WriteStringValue(DataCollectionEndpointResourceId); + } + if (options.Format != "W" && Optional.IsDefined(DataCollectionRuleImmutableId)) + { + writer.WritePropertyName("dataCollectionRuleImmutableId"u8); + writer.WriteStringValue(DataCollectionRuleImmutableId); + } + if (options.Format != "W" && Optional.IsDefined(IngestionEndpoints)) + { + writer.WritePropertyName("ingestionEndpoints"u8); + writer.WriteObjectValue(IngestionEndpoints, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureMonitorWorkspaceDefaultIngestionSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureMonitorWorkspaceDefaultIngestionSettings 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(AzureMonitorWorkspaceDefaultIngestionSettings)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureMonitorWorkspaceDefaultIngestionSettings(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureMonitorWorkspaceDefaultIngestionSettings DeserializeAzureMonitorWorkspaceDefaultIngestionSettings(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string dataCollectionRuleResourceId = default; + string dataCollectionEndpointResourceId = default; + string dataCollectionRuleImmutableId = default; + IngestionEndpoints ingestionEndpoints = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("dataCollectionRuleResourceId"u8)) + { + dataCollectionRuleResourceId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("dataCollectionEndpointResourceId"u8)) + { + dataCollectionEndpointResourceId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("dataCollectionRuleImmutableId"u8)) + { + dataCollectionRuleImmutableId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("ingestionEndpoints"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + ingestionEndpoints = IngestionEndpoints.DeserializeIngestionEndpoints(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureMonitorWorkspaceDefaultIngestionSettings(dataCollectionRuleResourceId, dataCollectionEndpointResourceId, dataCollectionRuleImmutableId, ingestionEndpoints, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceDefaultIngestionSettings.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceDefaultIngestionSettings.cs new file mode 100644 index 000000000000..62057bda4e5d --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceDefaultIngestionSettings.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The Data Collection Rule and Endpoint used for ingestion by default. + public partial class AzureMonitorWorkspaceDefaultIngestionSettings + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal AzureMonitorWorkspaceDefaultIngestionSettings() + { + } + + /// Initializes a new instance of . + /// The Azure resource Id of the default data collection rule for this Azure Monitor Workspace. + /// The Azure resource Id of the default data collection endpoint for this Azure Monitor Workspace. + /// The immutable Id of the default data collection rule for this Azure Monitor Workspace. + /// The ingestion endpoints for this Azure Monitor Workspace. + /// Keeps track of any properties unknown to the library. + internal AzureMonitorWorkspaceDefaultIngestionSettings(string dataCollectionRuleResourceId, string dataCollectionEndpointResourceId, string dataCollectionRuleImmutableId, IngestionEndpoints ingestionEndpoints, IDictionary additionalBinaryDataProperties) + { + DataCollectionRuleResourceId = dataCollectionRuleResourceId; + DataCollectionEndpointResourceId = dataCollectionEndpointResourceId; + DataCollectionRuleImmutableId = dataCollectionRuleImmutableId; + IngestionEndpoints = ingestionEndpoints; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Azure resource Id of the default data collection rule for this Azure Monitor Workspace. + public string DataCollectionRuleResourceId { get; } + + /// The Azure resource Id of the default data collection endpoint for this Azure Monitor Workspace. + public string DataCollectionEndpointResourceId { get; } + + /// The immutable Id of the default data collection rule for this Azure Monitor Workspace. + public string DataCollectionRuleImmutableId { get; } + + /// The ingestion endpoints for this Azure Monitor Workspace. + internal IngestionEndpoints IngestionEndpoints { get; } + + /// The metrics ingestion endpoint for this Azure Monitor Workspace. + public string IngestionEndpointsMetrics + { + get + { + return IngestionEndpoints is null ? default : IngestionEndpoints.Metrics; + } + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceMetrics.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceMetrics.Serialization.cs new file mode 100644 index 000000000000..b666ac215767 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceMetrics.Serialization.cs @@ -0,0 +1,167 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Properties related to the metrics container in the Azure Monitor Workspace. + public partial class AzureMonitorWorkspaceMetrics : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureMonitorWorkspaceMetrics 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 DeserializeAzureMonitorWorkspaceMetrics(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceMetrics)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceMetrics)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AzureMonitorWorkspaceMetrics IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceMetrics)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(PrometheusQueryEndpoint)) + { + writer.WritePropertyName("prometheusQueryEndpoint"u8); + writer.WriteStringValue(PrometheusQueryEndpoint); + } + if (options.Format != "W" && Optional.IsDefined(InternalId)) + { + writer.WritePropertyName("internalId"u8); + writer.WriteStringValue(InternalId); + } + if (Optional.IsDefined(EnableAccessUsingResourcePermissions)) + { + writer.WritePropertyName("enableAccessUsingResourcePermissions"u8); + writer.WriteBooleanValue(EnableAccessUsingResourcePermissions.Value); + } + 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. + AzureMonitorWorkspaceMetrics IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureMonitorWorkspaceMetrics 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(AzureMonitorWorkspaceMetrics)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureMonitorWorkspaceMetrics(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureMonitorWorkspaceMetrics DeserializeAzureMonitorWorkspaceMetrics(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string prometheusQueryEndpoint = default; + string internalId = default; + bool? enableAccessUsingResourcePermissions = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("prometheusQueryEndpoint"u8)) + { + prometheusQueryEndpoint = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("internalId"u8)) + { + internalId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("enableAccessUsingResourcePermissions"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enableAccessUsingResourcePermissions = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureMonitorWorkspaceMetrics(prometheusQueryEndpoint, internalId, enableAccessUsingResourcePermissions, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceMetrics.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceMetrics.cs new file mode 100644 index 000000000000..5f56eea0dfda --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceMetrics.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Properties related to the metrics container in the Azure Monitor Workspace. + public partial class AzureMonitorWorkspaceMetrics + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AzureMonitorWorkspaceMetrics() + { + } + + /// Initializes a new instance of . + /// The Prometheus query endpoint for the Azure Monitor Workspace. + /// An internal identifier for the metrics container. Only to be used by the system. + /// Flag that indicates whether to enable access using resource permissions. + /// Keeps track of any properties unknown to the library. + internal AzureMonitorWorkspaceMetrics(string prometheusQueryEndpoint, string internalId, bool? enableAccessUsingResourcePermissions, IDictionary additionalBinaryDataProperties) + { + PrometheusQueryEndpoint = prometheusQueryEndpoint; + InternalId = internalId; + EnableAccessUsingResourcePermissions = enableAccessUsingResourcePermissions; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Prometheus query endpoint for the Azure Monitor Workspace. + public string PrometheusQueryEndpoint { get; } + + /// An internal identifier for the metrics container. Only to be used by the system. + public string InternalId { get; } + + /// Flag that indicates whether to enable access using resource permissions. + public bool? EnableAccessUsingResourcePermissions { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceResourceListResult.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceResourceListResult.Serialization.cs new file mode 100644 index 000000000000..1fc9caae1f6c --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceResourceListResult.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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The response of a AzureMonitorWorkspaceResource list operation. + internal partial class AzureMonitorWorkspaceResourceListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureMonitorWorkspaceResourceListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureMonitorWorkspaceResourceListResult 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 DeserializeAzureMonitorWorkspaceResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AzureMonitorWorkspaceResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static AzureMonitorWorkspaceResourceListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureMonitorWorkspaceResourceListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceResourceListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (AzureMonitorWorkspaceResourceData 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. + AzureMonitorWorkspaceResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureMonitorWorkspaceResourceListResult 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(AzureMonitorWorkspaceResourceListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureMonitorWorkspaceResourceListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureMonitorWorkspaceResourceListResult DeserializeAzureMonitorWorkspaceResourceListResult(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(AzureMonitorWorkspaceResourceData.DeserializeAzureMonitorWorkspaceResourceData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureMonitorWorkspaceResourceListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceResourceListResult.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceResourceListResult.cs new file mode 100644 index 000000000000..eaa47d39b72f --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceResourceListResult.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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The response of a AzureMonitorWorkspaceResource list operation. + internal partial class AzureMonitorWorkspaceResourceListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The AzureMonitorWorkspaceResource items on this page. + internal AzureMonitorWorkspaceResourceListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The AzureMonitorWorkspaceResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal AzureMonitorWorkspaceResourceListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The AzureMonitorWorkspaceResource items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceResourcePatch.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceResourcePatch.Serialization.cs new file mode 100644 index 000000000000..f3be3e1f9c42 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceResourcePatch.Serialization.cs @@ -0,0 +1,211 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The type used for updating an Azure Monitor Workspace. + public partial class AzureMonitorWorkspaceResourcePatch : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureMonitorWorkspaceResourcePatch 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 DeserializeAzureMonitorWorkspaceResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceResourcePatch)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceResourcePatch)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AzureMonitorWorkspaceResourcePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(AzureMonitorWorkspaceResourcePatch azureMonitorWorkspaceResourcePatch) + { + if (azureMonitorWorkspaceResourcePatch == null) + { + return null; + } + return RequestContent.Create(azureMonitorWorkspaceResourcePatch, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureMonitorWorkspaceResourcePatch)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + ((IJsonModel)Identity).Write(writer, options.Format == "W" ? ModelSerializationExtensions.WireV3Options : ModelSerializationExtensions.JsonV3Options); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureMonitorWorkspaceResourcePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureMonitorWorkspaceResourcePatch 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(AzureMonitorWorkspaceResourcePatch)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureMonitorWorkspaceResourcePatch(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureMonitorWorkspaceResourcePatch DeserializeAzureMonitorWorkspaceResourcePatch(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + ManagedServiceIdentity identity = default; + AzureMonitorWorkspace properties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (prop.NameEquals("identity"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), options.Format == "W" ? ModelSerializationExtensions.WireV3Options : ModelSerializationExtensions.JsonV3Options, AzureResourceManagerMonitorWorkspacesContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = AzureMonitorWorkspace.DeserializeAzureMonitorWorkspace(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureMonitorWorkspaceResourcePatch(tags ?? new ChangeTrackingDictionary(), identity, properties, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceResourcePatch.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceResourcePatch.cs new file mode 100644 index 000000000000..386b1b5879fd --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureMonitorWorkspaceResourcePatch.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The type used for updating an Azure Monitor Workspace. + public partial class AzureMonitorWorkspaceResourcePatch + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AzureMonitorWorkspaceResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Resource tags. + /// The managed service identities assigned to this resource. + /// Resource properties. + /// Keeps track of any properties unknown to the library. + internal AzureMonitorWorkspaceResourcePatch(IDictionary tags, ManagedServiceIdentity identity, AzureMonitorWorkspace properties, IDictionary additionalBinaryDataProperties) + { + Tags = tags; + Identity = identity; + Properties = properties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Resource tags. + public IDictionary Tags { get; } + + /// The managed service identities assigned to this resource. + public ManagedServiceIdentity Identity { get; set; } + + /// Resource properties. + public AzureMonitorWorkspace Properties { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureResourceManagerMonitorWorkspacesContext.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureResourceManagerMonitorWorkspacesContext.cs new file mode 100644 index 000000000000..64fcb5d57548 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/AzureResourceManagerMonitorWorkspacesContext.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Monitor.Workspaces.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// + [ModelReaderWriterBuildable(typeof(AzureMonitorWorkspace))] + [ModelReaderWriterBuildable(typeof(AzureMonitorWorkspaceDefaultIngestionSettings))] + [ModelReaderWriterBuildable(typeof(AzureMonitorWorkspaceMetrics))] + [ModelReaderWriterBuildable(typeof(AzureMonitorWorkspaceResource))] + [ModelReaderWriterBuildable(typeof(AzureMonitorWorkspaceResourceData))] + [ModelReaderWriterBuildable(typeof(AzureMonitorWorkspaceResourceListResult))] + [ModelReaderWriterBuildable(typeof(AzureMonitorWorkspaceResourcePatch))] + [ModelReaderWriterBuildable(typeof(Background))] + [ModelReaderWriterBuildable(typeof(BackgroundDetails))] + [ModelReaderWriterBuildable(typeof(BackgroundVisualization))] + [ModelReaderWriterBuildable(typeof(FetchInvestigationResultParameters))] + [ModelReaderWriterBuildable(typeof(IngestionEndpoints))] + [ModelReaderWriterBuildable(typeof(InvestigationMetadata))] + [ModelReaderWriterBuildable(typeof(InvestigationResult))] + [ModelReaderWriterBuildable(typeof(IssueCreationNotificationType))] + [ModelReaderWriterBuildable(typeof(IssueNotificationType))] + [ModelReaderWriterBuildable(typeof(IssueProperties))] + [ModelReaderWriterBuildable(typeof(IssuePropertiesUpdate))] + [ModelReaderWriterBuildable(typeof(IssueResource))] + [ModelReaderWriterBuildable(typeof(IssueResourceData))] + [ModelReaderWriterBuildable(typeof(IssueResourceListResult))] + [ModelReaderWriterBuildable(typeof(IssueResourcePatch))] + [ModelReaderWriterBuildable(typeof(ListParameterContent))] + [ModelReaderWriterBuildable(typeof(ManagedServiceIdentity))] + [ModelReaderWriterBuildable(typeof(MetricsContainer))] + [ModelReaderWriterBuildable(typeof(MetricsContainerResource))] + [ModelReaderWriterBuildable(typeof(MetricsContainerResourceData))] + [ModelReaderWriterBuildable(typeof(MetricsContainerResourceListResult))] + [ModelReaderWriterBuildable(typeof(MonitorWorkspacesPrivateEndpointConnection))] + [ModelReaderWriterBuildable(typeof(MonitorWorkspacesPrivateLinkServiceConnectionState))] + [ModelReaderWriterBuildable(typeof(Notifications))] + [ModelReaderWriterBuildable(typeof(OnChangeNotificationType))] + [ModelReaderWriterBuildable(typeof(PagedRelatedAlert))] + [ModelReaderWriterBuildable(typeof(PagedRelatedResource))] + [ModelReaderWriterBuildable(typeof(PrivateEndpoint))] + [ModelReaderWriterBuildable(typeof(PrivateEndpointConnectionProperties))] + [ModelReaderWriterBuildable(typeof(RelatedAlert))] + [ModelReaderWriterBuildable(typeof(RelatedAlerts))] + [ModelReaderWriterBuildable(typeof(RelatedResource))] + [ModelReaderWriterBuildable(typeof(RelatedResources))] + [ModelReaderWriterBuildable(typeof(ResponseError))] + [ModelReaderWriterBuildable(typeof(SystemData))] + [ModelReaderWriterBuildable(typeof(TimeBasedUpdatesNotificationType))] + [ModelReaderWriterBuildable(typeof(UnknownIssueNotificationType))] + [ModelReaderWriterBuildable(typeof(UserAssignedIdentity))] + public partial class AzureResourceManagerMonitorWorkspacesContext : ModelReaderWriterContext + { + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Background.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Background.Serialization.cs new file mode 100644 index 000000000000..5a46b5510b0f --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Background.Serialization.cs @@ -0,0 +1,177 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The issue background information. + public partial class Background : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Background 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 DeserializeBackground(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Background)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(Background)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + Background IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Background)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (Optional.IsCollectionDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteStartArray(); + foreach (BackgroundDetails item in Details) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + Background IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Background 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(Background)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBackground(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Background DeserializeBackground(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = default; + string text = default; + IList details = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("text"u8)) + { + text = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("details"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(BackgroundDetails.DeserializeBackgroundDetails(item, options)); + } + details = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new Background(@type, text, details ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Background.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Background.cs new file mode 100644 index 000000000000..e52829345a0f --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Background.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 Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The issue background information. + public partial class Background + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public Background() + { + Details = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The background type. + /// The background text. + /// The background details. + /// Keeps track of any properties unknown to the library. + internal Background(string @type, string text, IList details, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Text = text; + Details = details; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The background type. + public string Type { get; set; } + + /// The background text. + public string Text { get; set; } + + /// The background details. + public IList Details { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/BackgroundDetails.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/BackgroundDetails.Serialization.cs new file mode 100644 index 000000000000..f0cc910fd94d --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/BackgroundDetails.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// A background details element. + public partial class BackgroundDetails : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BackgroundDetails() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BackgroundDetails 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 DeserializeBackgroundDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BackgroundDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(BackgroundDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + BackgroundDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BackgroundDetails)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + 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. + BackgroundDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BackgroundDetails 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(BackgroundDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBackgroundDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BackgroundDetails DeserializeBackgroundDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("value"u8)) + { + value = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BackgroundDetails(name, value, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/BackgroundDetails.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/BackgroundDetails.cs new file mode 100644 index 000000000000..70d2274ee4b4 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/BackgroundDetails.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// A background details element. + public partial class BackgroundDetails + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The background details name. + /// The background details value. + /// or is null. + public BackgroundDetails(string name, string value) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(value, nameof(value)); + + Name = name; + Value = value; + } + + /// Initializes a new instance of . + /// The background details name. + /// The background details value. + /// Keeps track of any properties unknown to the library. + internal BackgroundDetails(string name, string value, IDictionary additionalBinaryDataProperties) + { + Name = name; + Value = value; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The background details name. + public string Name { get; set; } + + /// The background details value. + public string Value { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/BackgroundVisualization.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/BackgroundVisualization.Serialization.cs new file mode 100644 index 000000000000..87efda2b11e5 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/BackgroundVisualization.Serialization.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The issue background visualization. + public partial class BackgroundVisualization : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BackgroundVisualization() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BackgroundVisualization 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 DeserializeBackgroundVisualization(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BackgroundVisualization)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(BackgroundVisualization)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + BackgroundVisualization IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(BackgroundVisualization backgroundVisualization) + { + if (backgroundVisualization == null) + { + return null; + } + return RequestContent.Create(backgroundVisualization, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static BackgroundVisualization FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBackgroundVisualization(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BackgroundVisualization)} does not support writing '{format}' format."); + } + writer.WritePropertyName("visualization"u8); + writer.WriteStringValue(Visualization); + if (options.Format != "W") + { + writer.WritePropertyName("origin"u8); + writer.WriteObjectValue(Origin, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BackgroundVisualization IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BackgroundVisualization 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(BackgroundVisualization)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBackgroundVisualization(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BackgroundVisualization DeserializeBackgroundVisualization(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string visualization = default; + Models.Origin origin = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("visualization"u8)) + { + visualization = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("origin"u8)) + { + origin = Models.Origin.DeserializeOrigin(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BackgroundVisualization(visualization, origin, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/BackgroundVisualization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/BackgroundVisualization.cs new file mode 100644 index 000000000000..51d2e785f72e --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/BackgroundVisualization.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.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The issue background visualization. + public partial class BackgroundVisualization + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The background visualization content, in Adaptive Card format. + /// is null. + public BackgroundVisualization(string visualization) + { + Argument.AssertNotNull(visualization, nameof(visualization)); + + Visualization = visualization; + } + + /// Initializes a new instance of . + /// The background visualization content, in Adaptive Card format. + /// The background visualization origin. + /// Keeps track of any properties unknown to the library. + internal BackgroundVisualization(string visualization, Models.Origin origin, IDictionary additionalBinaryDataProperties) + { + Visualization = visualization; + Origin = origin; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The background visualization content, in Adaptive Card format. + public string Visualization { get; set; } + + /// The background visualization origin. + public Models.Origin Origin { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/FetchInvestigationResultParameters.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/FetchInvestigationResultParameters.Serialization.cs new file mode 100644 index 000000000000..8c5fe09267c6 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/FetchInvestigationResultParameters.Serialization.cs @@ -0,0 +1,154 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Parameters provided to get the investigation result. + public partial class FetchInvestigationResultParameters : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal FetchInvestigationResultParameters() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FetchInvestigationResultParameters 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 DeserializeFetchInvestigationResultParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FetchInvestigationResultParameters)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(FetchInvestigationResultParameters)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + FetchInvestigationResultParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(FetchInvestigationResultParameters fetchInvestigationResultParameters) + { + if (fetchInvestigationResultParameters == null) + { + return null; + } + return RequestContent.Create(fetchInvestigationResultParameters, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FetchInvestigationResultParameters)} does not support writing '{format}' format."); + } + writer.WritePropertyName("investigationId"u8); + writer.WriteStringValue(InvestigationId); + 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. + FetchInvestigationResultParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FetchInvestigationResultParameters 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(FetchInvestigationResultParameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFetchInvestigationResultParameters(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FetchInvestigationResultParameters DeserializeFetchInvestigationResultParameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Guid investigationId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("investigationId"u8)) + { + investigationId = new Guid(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new FetchInvestigationResultParameters(investigationId, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/FetchInvestigationResultParameters.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/FetchInvestigationResultParameters.cs new file mode 100644 index 000000000000..0cae8e496148 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/FetchInvestigationResultParameters.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Parameters provided to get the investigation result. + public partial class FetchInvestigationResultParameters + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The unique identifier of the investigation. + public FetchInvestigationResultParameters(Guid investigationId) + { + InvestigationId = investigationId; + } + + /// Initializes a new instance of . + /// The unique identifier of the investigation. + /// Keeps track of any properties unknown to the library. + internal FetchInvestigationResultParameters(Guid investigationId, IDictionary additionalBinaryDataProperties) + { + InvestigationId = investigationId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique identifier of the investigation. + public Guid InvestigationId { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IngestionEndpoints.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IngestionEndpoints.Serialization.cs new file mode 100644 index 000000000000..7702ea48a0ec --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IngestionEndpoints.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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The ingestion endpoints for an Azure Monitor Workspace. + internal partial class IngestionEndpoints : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual IngestionEndpoints 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 DeserializeIngestionEndpoints(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IngestionEndpoints)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(IngestionEndpoints)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + IngestionEndpoints IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IngestionEndpoints)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(Metrics)) + { + writer.WritePropertyName("metrics"u8); + writer.WriteStringValue(Metrics); + } + 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. + IngestionEndpoints IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual IngestionEndpoints 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(IngestionEndpoints)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIngestionEndpoints(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static IngestionEndpoints DeserializeIngestionEndpoints(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string metrics = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metrics"u8)) + { + metrics = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new IngestionEndpoints(metrics, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IngestionEndpoints.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IngestionEndpoints.cs new file mode 100644 index 000000000000..95668b09f5b5 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IngestionEndpoints.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.Monitor.Workspaces.Models +{ + /// The ingestion endpoints for an Azure Monitor Workspace. + internal partial class IngestionEndpoints + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal IngestionEndpoints() + { + } + + /// Initializes a new instance of . + /// The metrics ingestion endpoint for this Azure Monitor Workspace. + /// Keeps track of any properties unknown to the library. + internal IngestionEndpoints(string metrics, IDictionary additionalBinaryDataProperties) + { + Metrics = metrics; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The metrics ingestion endpoint for this Azure Monitor Workspace. + public string Metrics { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/InvestigationMetadata.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/InvestigationMetadata.Serialization.cs new file mode 100644 index 000000000000..db0a490c8fb7 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/InvestigationMetadata.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Properties of the current investigation. + public partial class InvestigationMetadata : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InvestigationMetadata() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InvestigationMetadata 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 DeserializeInvestigationMetadata(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InvestigationMetadata)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(InvestigationMetadata)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + InvestigationMetadata IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InvestigationMetadata)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("createdAt"u8); + writer.WriteStringValue(CreatedOn, "O"); + 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. + InvestigationMetadata IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InvestigationMetadata 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(InvestigationMetadata)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInvestigationMetadata(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InvestigationMetadata DeserializeInvestigationMetadata(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Guid id = default; + DateTimeOffset createdOn = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = new Guid(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("createdAt"u8)) + { + createdOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InvestigationMetadata(id, createdOn, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/InvestigationMetadata.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/InvestigationMetadata.cs new file mode 100644 index 000000000000..ad33445795be --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/InvestigationMetadata.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Properties of the current investigation. + public partial class InvestigationMetadata + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The unique identifier of the investigation. + /// The creation time of the investigation (in UTC). + internal InvestigationMetadata(Guid id, DateTimeOffset createdOn) + { + Id = id; + CreatedOn = createdOn; + } + + /// Initializes a new instance of . + /// The unique identifier of the investigation. + /// The creation time of the investigation (in UTC). + /// Keeps track of any properties unknown to the library. + internal InvestigationMetadata(Guid id, DateTimeOffset createdOn, IDictionary additionalBinaryDataProperties) + { + Id = id; + CreatedOn = createdOn; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique identifier of the investigation. + public Guid Id { get; } + + /// The creation time of the investigation (in UTC). + public DateTimeOffset CreatedOn { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/InvestigationResult.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/InvestigationResult.Serialization.cs new file mode 100644 index 000000000000..95b50ce5f89a --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/InvestigationResult.Serialization.cs @@ -0,0 +1,221 @@ +// 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.Core; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Details about the investigation result. + public partial class InvestigationResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InvestigationResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InvestigationResult 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 DeserializeInvestigationResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InvestigationResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(InvestigationResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + InvestigationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(InvestigationResult investigationResult) + { + if (investigationResult == null) + { + return null; + } + return RequestContent.Create(investigationResult, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static InvestigationResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInvestigationResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InvestigationResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + if (Optional.IsDefined(Origin)) + { + writer.WritePropertyName("origin"u8); + writer.WriteObjectValue(Origin, options); + } + if (Optional.IsDefined(CreatedOn)) + { + writer.WritePropertyName("createdAt"u8); + writer.WriteStringValue(CreatedOn.Value, "O"); + } + if (Optional.IsDefined(LastModifiedOn)) + { + writer.WritePropertyName("lastModifiedAt"u8); + writer.WriteStringValue(LastModifiedOn.Value, "O"); + } + writer.WritePropertyName("result"u8); + writer.WriteStringValue(Result); + 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. + InvestigationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InvestigationResult 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(InvestigationResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInvestigationResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InvestigationResult DeserializeInvestigationResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + Models.Origin origin = default; + DateTimeOffset? createdOn = default; + DateTimeOffset? lastModifiedOn = default; + string result = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("origin"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + origin = Models.Origin.DeserializeOrigin(prop.Value, options); + continue; + } + if (prop.NameEquals("createdAt"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("lastModifiedAt"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("result"u8)) + { + result = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InvestigationResult( + id, + origin, + createdOn, + lastModifiedOn, + result, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/InvestigationResult.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/InvestigationResult.cs new file mode 100644 index 000000000000..95dfcc77ac7e --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/InvestigationResult.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Details about the investigation result. + public partial class InvestigationResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The identifier of the investigation. + /// The result of this investigation. + /// or is null. + public InvestigationResult(string id, string result) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(result, nameof(result)); + + Id = id; + Result = result; + } + + /// Initializes a new instance of . + /// The identifier of the investigation. + /// The origin of the investigation. + /// The creation time of the investigation (in UTC). + /// The last update time of the investigation (in UTC). + /// The result of this investigation. + /// Keeps track of any properties unknown to the library. + internal InvestigationResult(string id, Models.Origin origin, DateTimeOffset? createdOn, DateTimeOffset? lastModifiedOn, string result, IDictionary additionalBinaryDataProperties) + { + Id = id; + Origin = origin; + CreatedOn = createdOn; + LastModifiedOn = lastModifiedOn; + Result = result; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The identifier of the investigation. + public string Id { get; set; } + + /// The origin of the investigation. + public Models.Origin Origin { get; set; } + + /// The creation time of the investigation (in UTC). + public DateTimeOffset? CreatedOn { get; set; } + + /// The last update time of the investigation (in UTC). + public DateTimeOffset? LastModifiedOn { get; set; } + + /// The result of this investigation. + public string Result { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueCreationNotificationType.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueCreationNotificationType.Serialization.cs new file mode 100644 index 000000000000..323002208c4a --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueCreationNotificationType.Serialization.cs @@ -0,0 +1,122 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Notification type for issue creation events. + public partial class IssueCreationNotificationType : IssueNotificationType, IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected override IssueNotificationType 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 DeserializeIssueCreationNotificationType(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IssueCreationNotificationType)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(IssueCreationNotificationType)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + IssueCreationNotificationType IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (IssueCreationNotificationType)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IssueCreationNotificationType)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + IssueCreationNotificationType IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (IssueCreationNotificationType)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override IssueNotificationType 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(IssueCreationNotificationType)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIssueCreationNotificationType(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static IssueCreationNotificationType DeserializeIssueCreationNotificationType(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UpdateType updateType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("updateType"u8)) + { + updateType = new UpdateType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new IssueCreationNotificationType(updateType, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueCreationNotificationType.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueCreationNotificationType.cs new file mode 100644 index 000000000000..3f0a4825f77d --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueCreationNotificationType.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Notification type for issue creation events. + public partial class IssueCreationNotificationType : IssueNotificationType + { + /// Initializes a new instance of . + public IssueCreationNotificationType() : base(UpdateType.IssueCreation) + { + } + + /// Initializes a new instance of . + /// The type of update that triggers the notification. + /// Keeps track of any properties unknown to the library. + internal IssueCreationNotificationType(UpdateType updateType, IDictionary additionalBinaryDataProperties) : base(updateType, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueNotificationType.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueNotificationType.Serialization.cs new file mode 100644 index 000000000000..96afed3c90f1 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueNotificationType.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// + /// Base properties for an issue notification type + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + [PersistableModelProxy(typeof(UnknownIssueNotificationType))] + public abstract partial class IssueNotificationType : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal IssueNotificationType() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual IssueNotificationType 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 DeserializeIssueNotificationType(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IssueNotificationType)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(IssueNotificationType)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + IssueNotificationType IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IssueNotificationType)} does not support writing '{format}' format."); + } + writer.WritePropertyName("updateType"u8); + writer.WriteStringValue(UpdateType.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. + IssueNotificationType IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual IssueNotificationType 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(IssueNotificationType)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIssueNotificationType(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static IssueNotificationType DeserializeIssueNotificationType(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("updateType"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "IssueCreation": + return IssueCreationNotificationType.DeserializeIssueCreationNotificationType(element, options); + case "OnChange": + return OnChangeNotificationType.DeserializeOnChangeNotificationType(element, options); + case "TimeBased": + return TimeBasedUpdatesNotificationType.DeserializeTimeBasedUpdatesNotificationType(element, options); + } + } + return UnknownIssueNotificationType.DeserializeUnknownIssueNotificationType(element, options); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueNotificationType.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueNotificationType.cs new file mode 100644 index 000000000000..0174b4fc3dc2 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueNotificationType.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.Monitor.Workspaces.Models +{ + /// + /// Base properties for an issue notification type + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + public abstract partial class IssueNotificationType + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of update that triggers the notification. + private protected IssueNotificationType(UpdateType updateType) + { + UpdateType = updateType; + } + + /// Initializes a new instance of . + /// The type of update that triggers the notification. + /// Keeps track of any properties unknown to the library. + internal IssueNotificationType(UpdateType updateType, IDictionary additionalBinaryDataProperties) + { + UpdateType = updateType; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of update that triggers the notification. + internal UpdateType UpdateType { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueProperties.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueProperties.Serialization.cs new file mode 100644 index 000000000000..a8b939577341 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueProperties.Serialization.cs @@ -0,0 +1,254 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The issue properties. + public partial class IssueProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal IssueProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual IssueProperties 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 DeserializeIssueProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IssueProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(IssueProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + IssueProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IssueProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("title"u8); + writer.WriteStringValue(Title); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("severity"u8); + writer.WriteStringValue(Severity); + if (options.Format != "W") + { + writer.WritePropertyName("investigations"u8); + writer.WriteStartArray(); + foreach (InvestigationMetadata item in Investigations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("impactTime"u8); + writer.WriteStringValue(ImpactOn, "O"); + if (options.Format != "W") + { + writer.WritePropertyName("investigationsCount"u8); + writer.WriteNumberValue(InvestigationsCount); + } + if (Optional.IsDefined(Background)) + { + writer.WritePropertyName("background"u8); + writer.WriteObjectValue(Background, options); + } + if (Optional.IsDefined(Notifications)) + { + writer.WritePropertyName("notifications"u8); + writer.WriteObjectValue(Notifications, options); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + IssueProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual IssueProperties 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(IssueProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIssueProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static IssueProperties DeserializeIssueProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string title = default; + Status status = default; + string severity = default; + IReadOnlyList investigations = default; + DateTimeOffset impactOn = default; + int investigationsCount = default; + Background background = default; + Notifications notifications = default; + ResourceProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("title"u8)) + { + title = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new Status(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("severity"u8)) + { + severity = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("investigations"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InvestigationMetadata.DeserializeInvestigationMetadata(item, options)); + } + investigations = array; + continue; + } + if (prop.NameEquals("impactTime"u8)) + { + impactOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("investigationsCount"u8)) + { + investigationsCount = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("background"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + background = Background.DeserializeBackground(prop.Value, options); + continue; + } + if (prop.NameEquals("notifications"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + notifications = Notifications.DeserializeNotifications(prop.Value, options); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ResourceProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new IssueProperties( + title, + status, + severity, + investigations, + impactOn, + investigationsCount, + background, + notifications, + provisioningState, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueProperties.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueProperties.cs new file mode 100644 index 000000000000..d58040a0da86 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueProperties.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The issue properties. + public partial class IssueProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The issue title. + /// The issue status. + /// The issue severity. + /// The issue impact time (in UTC). + /// or is null. + public IssueProperties(string title, Status status, string severity, DateTimeOffset impactOn) + { + Argument.AssertNotNull(title, nameof(title)); + Argument.AssertNotNull(severity, nameof(severity)); + + Title = title; + Status = status; + Severity = severity; + Investigations = new ChangeTrackingList(); + ImpactOn = impactOn; + } + + /// Initializes a new instance of . + /// The issue title. + /// The issue status. + /// The issue severity. + /// The list of investigations in the issue. + /// The issue impact time (in UTC). + /// The number of investigations in the issue. + /// The issue background information. + /// The issue notification settings. + /// The provisioning state of the resource. + /// Keeps track of any properties unknown to the library. + internal IssueProperties(string title, Status status, string severity, IReadOnlyList investigations, DateTimeOffset impactOn, int investigationsCount, Background background, Notifications notifications, ResourceProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + Title = title; + Status = status; + Severity = severity; + Investigations = investigations; + ImpactOn = impactOn; + InvestigationsCount = investigationsCount; + Background = background; + Notifications = notifications; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The issue title. + public string Title { get; set; } + + /// The issue status. + public Status Status { get; set; } + + /// The issue severity. + public string Severity { get; set; } + + /// The list of investigations in the issue. + public IReadOnlyList Investigations { get; } + + /// The issue impact time (in UTC). + public DateTimeOffset ImpactOn { get; set; } + + /// The number of investigations in the issue. + public int InvestigationsCount { get; } + + /// The issue background information. + public Background Background { get; set; } + + /// The issue notification settings. + public Notifications Notifications { get; set; } + + /// The provisioning state of the resource. + public ResourceProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssuePropertiesUpdate.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssuePropertiesUpdate.Serialization.cs new file mode 100644 index 000000000000..339fd8c35587 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssuePropertiesUpdate.Serialization.cs @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The issue properties for update. + public partial class IssuePropertiesUpdate : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual IssuePropertiesUpdate 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 DeserializeIssuePropertiesUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IssuePropertiesUpdate)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(IssuePropertiesUpdate)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + IssuePropertiesUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IssuePropertiesUpdate)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Title)) + { + writer.WritePropertyName("title"u8); + writer.WriteStringValue(Title); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (Optional.IsDefined(Severity)) + { + writer.WritePropertyName("severity"u8); + writer.WriteStringValue(Severity); + } + if (Optional.IsDefined(ImpactOn)) + { + writer.WritePropertyName("impactTime"u8); + writer.WriteStringValue(ImpactOn.Value, "O"); + } + if (Optional.IsDefined(Background)) + { + writer.WritePropertyName("background"u8); + writer.WriteObjectValue(Background, options); + } + if (Optional.IsDefined(Notifications)) + { + writer.WritePropertyName("notifications"u8); + writer.WriteObjectValue(Notifications, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + IssuePropertiesUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual IssuePropertiesUpdate 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(IssuePropertiesUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIssuePropertiesUpdate(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static IssuePropertiesUpdate DeserializeIssuePropertiesUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string title = default; + Status? status = default; + string severity = default; + DateTimeOffset? impactOn = default; + Background background = default; + Notifications notifications = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("title"u8)) + { + title = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new Status(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("severity"u8)) + { + severity = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("impactTime"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + impactOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("background"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + background = Background.DeserializeBackground(prop.Value, options); + continue; + } + if (prop.NameEquals("notifications"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + notifications = Notifications.DeserializeNotifications(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new IssuePropertiesUpdate( + title, + status, + severity, + impactOn, + background, + notifications, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssuePropertiesUpdate.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssuePropertiesUpdate.cs new file mode 100644 index 000000000000..e8545a51a76c --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssuePropertiesUpdate.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The issue properties for update. + public partial class IssuePropertiesUpdate + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public IssuePropertiesUpdate() + { + } + + /// Initializes a new instance of . + /// The issue title. + /// The issue status. + /// The issue severity. + /// The issue impact time (in UTC). + /// The issue background information. + /// The issue notification settings. + /// Keeps track of any properties unknown to the library. + internal IssuePropertiesUpdate(string title, Status? status, string severity, DateTimeOffset? impactOn, Background background, Notifications notifications, IDictionary additionalBinaryDataProperties) + { + Title = title; + Status = status; + Severity = severity; + ImpactOn = impactOn; + Background = background; + Notifications = notifications; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The issue title. + public string Title { get; set; } + + /// The issue status. + public Status? Status { get; set; } + + /// The issue severity. + public string Severity { get; set; } + + /// The issue impact time (in UTC). + public DateTimeOffset? ImpactOn { get; set; } + + /// The issue background information. + public Background Background { get; set; } + + /// The issue notification settings. + public Notifications Notifications { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueResourceListResult.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueResourceListResult.Serialization.cs new file mode 100644 index 000000000000..046fa2f57c7b --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueResourceListResult.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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The response of a IssueResource list operation. + internal partial class IssueResourceListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal IssueResourceListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual IssueResourceListResult 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 DeserializeIssueResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IssueResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(IssueResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + IssueResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static IssueResourceListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeIssueResourceListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IssueResourceListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (IssueResourceData 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. + IssueResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual IssueResourceListResult 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(IssueResourceListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIssueResourceListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static IssueResourceListResult DeserializeIssueResourceListResult(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(IssueResourceData.DeserializeIssueResourceData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new IssueResourceListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueResourceListResult.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueResourceListResult.cs new file mode 100644 index 000000000000..b394584773e7 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueResourceListResult.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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The response of a IssueResource list operation. + internal partial class IssueResourceListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The IssueResource items on this page. + internal IssueResourceListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The IssueResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal IssueResourceListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The IssueResource items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueResourcePatch.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueResourcePatch.Serialization.cs new file mode 100644 index 000000000000..b0bbfafa0e81 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueResourcePatch.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.Core; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The Issue resource update. + public partial class IssueResourcePatch : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual IssueResourcePatch 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 DeserializeIssueResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IssueResourcePatch)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(IssueResourcePatch)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + IssueResourcePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(IssueResourcePatch issueResourcePatch) + { + if (issueResourcePatch == null) + { + return null; + } + return RequestContent.Create(issueResourcePatch, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IssueResourcePatch)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + IssueResourcePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual IssueResourcePatch 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(IssueResourcePatch)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIssueResourcePatch(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static IssueResourcePatch DeserializeIssueResourcePatch(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IssuePropertiesUpdate properties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = IssuePropertiesUpdate.DeserializeIssuePropertiesUpdate(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new IssueResourcePatch(properties, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueResourcePatch.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueResourcePatch.cs new file mode 100644 index 000000000000..7ce6853fceb7 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/IssueResourcePatch.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.Monitor.Workspaces.Models +{ + /// The Issue resource update. + public partial class IssueResourcePatch + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public IssueResourcePatch() + { + } + + /// Initializes a new instance of . + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal IssueResourcePatch(IssuePropertiesUpdate properties, IDictionary additionalBinaryDataProperties) + { + Properties = properties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The resource-specific properties for this resource. + public IssuePropertiesUpdate Properties { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/ListParameterContent.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/ListParameterContent.Serialization.cs new file mode 100644 index 000000000000..3992c865114d --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/ListParameterContent.Serialization.cs @@ -0,0 +1,152 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Parameters for listing related entities. + public partial class ListParameterContent : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ListParameterContent 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 DeserializeListParameterContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListParameterContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(ListParameterContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ListParameterContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ListParameterContent listParameterContent) + { + if (listParameterContent == null) + { + return null; + } + return RequestContent.Create(listParameterContent, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ListParameterContent)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Filter)) + { + writer.WritePropertyName("filter"u8); + writer.WriteStringValue(Filter); + } + 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. + ListParameterContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ListParameterContent 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(ListParameterContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeListParameterContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ListParameterContent DeserializeListParameterContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string filter = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("filter"u8)) + { + filter = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ListParameterContent(filter, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/ListParameterContent.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/ListParameterContent.cs new file mode 100644 index 000000000000..e3c769253685 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/ListParameterContent.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.Monitor.Workspaces.Models +{ + /// Parameters for listing related entities. + public partial class ListParameterContent + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ListParameterContent() + { + } + + /// Initializes a new instance of . + /// The filter to apply on the operation. For example, to filter by relevance, use "$filter=relevance eq 'Relevant'". Note: this property is currently a placeholder and is not in use. + /// Keeps track of any properties unknown to the library. + internal ListParameterContent(string filter, IDictionary additionalBinaryDataProperties) + { + Filter = filter; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The filter to apply on the operation. For example, to filter by relevance, use "$filter=relevance eq 'Relevant'". Note: this property is currently a placeholder and is not in use. + public string Filter { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MetricsContainer.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MetricsContainer.Serialization.cs new file mode 100644 index 000000000000..a9e2a75abda9 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MetricsContainer.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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Properties of a metrics container. + public partial class MetricsContainer : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MetricsContainer 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 DeserializeMetricsContainer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricsContainer)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(MetricsContainer)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + MetricsContainer IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricsContainer)} 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(Version)) + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MetricsContainer IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MetricsContainer 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(MetricsContainer)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricsContainer(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MetricsContainer DeserializeMetricsContainer(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceProvisioningState? provisioningState = default; + string version = 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 ResourceProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MetricsContainer(provisioningState, version, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MetricsContainer.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MetricsContainer.cs new file mode 100644 index 000000000000..87d4cd3eebdc --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MetricsContainer.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.Monitor.Workspaces.Models +{ + /// Properties of a metrics container. + public partial class MetricsContainer + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public MetricsContainer() + { + } + + /// Initializes a new instance of . + /// The provisioning state of the metrics container. + /// The version of Metrics Query Service that this AMW will use for all metric queries. + /// Keeps track of any properties unknown to the library. + internal MetricsContainer(ResourceProvisioningState? provisioningState, string version, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + Version = version; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The provisioning state of the metrics container. + public ResourceProvisioningState? ProvisioningState { get; } + + /// The version of Metrics Query Service that this AMW will use for all metric queries. + public string Version { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MetricsContainerResourceListResult.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MetricsContainerResourceListResult.Serialization.cs new file mode 100644 index 000000000000..403b728a194d --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MetricsContainerResourceListResult.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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The response of a MetricsContainerResource list operation. + internal partial class MetricsContainerResourceListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MetricsContainerResourceListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MetricsContainerResourceListResult 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 DeserializeMetricsContainerResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricsContainerResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(MetricsContainerResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + MetricsContainerResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static MetricsContainerResourceListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetricsContainerResourceListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricsContainerResourceListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (MetricsContainerResourceData 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. + MetricsContainerResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MetricsContainerResourceListResult 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(MetricsContainerResourceListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricsContainerResourceListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MetricsContainerResourceListResult DeserializeMetricsContainerResourceListResult(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(MetricsContainerResourceData.DeserializeMetricsContainerResourceData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MetricsContainerResourceListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MetricsContainerResourceListResult.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MetricsContainerResourceListResult.cs new file mode 100644 index 000000000000..3b2c8a9c1842 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MetricsContainerResourceListResult.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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The response of a MetricsContainerResource list operation. + internal partial class MetricsContainerResourceListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The MetricsContainerResource items on this page. + internal MetricsContainerResourceListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The MetricsContainerResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal MetricsContainerResourceListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The MetricsContainerResource items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateEndpointConnection.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateEndpointConnection.Serialization.cs new file mode 100644 index 000000000000..9fe87ec67efd --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateEndpointConnection.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The private endpoint connection resource. + public partial class MonitorWorkspacesPrivateEndpointConnection : ResourceData, IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMonitorWorkspacesPrivateEndpointConnection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MonitorWorkspacesPrivateEndpointConnection)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(MonitorWorkspacesPrivateEndpointConnection)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + MonitorWorkspacesPrivateEndpointConnection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MonitorWorkspacesPrivateEndpointConnection)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MonitorWorkspacesPrivateEndpointConnection)} 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. + MonitorWorkspacesPrivateEndpointConnection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MonitorWorkspacesPrivateEndpointConnection)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(MonitorWorkspacesPrivateEndpointConnection)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMonitorWorkspacesPrivateEndpointConnection(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MonitorWorkspacesPrivateEndpointConnection DeserializeMonitorWorkspacesPrivateEndpointConnection(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + PrivateEndpointConnectionProperties properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerMonitorWorkspacesContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = PrivateEndpointConnectionProperties.DeserializePrivateEndpointConnectionProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MonitorWorkspacesPrivateEndpointConnection( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateEndpointConnection.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateEndpointConnection.cs new file mode 100644 index 000000000000..ab3402583308 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateEndpointConnection.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The private endpoint connection resource. + public partial class MonitorWorkspacesPrivateEndpointConnection : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal MonitorWorkspacesPrivateEndpointConnection() + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// The private endpoint connection properties. + internal MonitorWorkspacesPrivateEndpointConnection(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, PrivateEndpointConnectionProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The private endpoint connection properties. + public PrivateEndpointConnectionProperties Properties { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateEndpointConnectionProvisioningState.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateEndpointConnectionProvisioningState.cs new file mode 100644 index 000000000000..8cd8f7a2575d --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateEndpointConnectionProvisioningState.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The current provisioning state. + public readonly partial struct MonitorWorkspacesPrivateEndpointConnectionProvisioningState : 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 MonitorWorkspacesPrivateEndpointConnectionProvisioningState(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Connection has been provisioned. + public static MonitorWorkspacesPrivateEndpointConnectionProvisioningState Succeeded { get; } = new MonitorWorkspacesPrivateEndpointConnectionProvisioningState(SucceededValue); + + /// Connection is being created. + public static MonitorWorkspacesPrivateEndpointConnectionProvisioningState Creating { get; } = new MonitorWorkspacesPrivateEndpointConnectionProvisioningState(CreatingValue); + + /// Connection is being deleted. + public static MonitorWorkspacesPrivateEndpointConnectionProvisioningState Deleting { get; } = new MonitorWorkspacesPrivateEndpointConnectionProvisioningState(DeletingValue); + + /// Connection provisioning has failed. + public static MonitorWorkspacesPrivateEndpointConnectionProvisioningState Failed { get; } = new MonitorWorkspacesPrivateEndpointConnectionProvisioningState(FailedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(MonitorWorkspacesPrivateEndpointConnectionProvisioningState left, MonitorWorkspacesPrivateEndpointConnectionProvisioningState 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 !=(MonitorWorkspacesPrivateEndpointConnectionProvisioningState left, MonitorWorkspacesPrivateEndpointConnectionProvisioningState right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator MonitorWorkspacesPrivateEndpointConnectionProvisioningState(string value) => new MonitorWorkspacesPrivateEndpointConnectionProvisioningState(value); + + /// Converts a string to a . + /// The value. + public static implicit operator MonitorWorkspacesPrivateEndpointConnectionProvisioningState?(string value) => value == null ? null : new MonitorWorkspacesPrivateEndpointConnectionProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MonitorWorkspacesPrivateEndpointConnectionProvisioningState other && Equals(other); + + /// + public bool Equals(MonitorWorkspacesPrivateEndpointConnectionProvisioningState 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateEndpointServiceConnectionStatus.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateEndpointServiceConnectionStatus.cs new file mode 100644 index 000000000000..858056ff48c1 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateEndpointServiceConnectionStatus.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The private endpoint connection status. + public readonly partial struct MonitorWorkspacesPrivateEndpointServiceConnectionStatus : 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 MonitorWorkspacesPrivateEndpointServiceConnectionStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Connection waiting for approval or rejection. + public static MonitorWorkspacesPrivateEndpointServiceConnectionStatus Pending { get; } = new MonitorWorkspacesPrivateEndpointServiceConnectionStatus(PendingValue); + + /// Connection approved. + public static MonitorWorkspacesPrivateEndpointServiceConnectionStatus Approved { get; } = new MonitorWorkspacesPrivateEndpointServiceConnectionStatus(ApprovedValue); + + /// Connection Rejected. + public static MonitorWorkspacesPrivateEndpointServiceConnectionStatus Rejected { get; } = new MonitorWorkspacesPrivateEndpointServiceConnectionStatus(RejectedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(MonitorWorkspacesPrivateEndpointServiceConnectionStatus left, MonitorWorkspacesPrivateEndpointServiceConnectionStatus 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 !=(MonitorWorkspacesPrivateEndpointServiceConnectionStatus left, MonitorWorkspacesPrivateEndpointServiceConnectionStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator MonitorWorkspacesPrivateEndpointServiceConnectionStatus(string value) => new MonitorWorkspacesPrivateEndpointServiceConnectionStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator MonitorWorkspacesPrivateEndpointServiceConnectionStatus?(string value) => value == null ? null : new MonitorWorkspacesPrivateEndpointServiceConnectionStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MonitorWorkspacesPrivateEndpointServiceConnectionStatus other && Equals(other); + + /// + public bool Equals(MonitorWorkspacesPrivateEndpointServiceConnectionStatus 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateLinkServiceConnectionState.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateLinkServiceConnectionState.Serialization.cs new file mode 100644 index 000000000000..459c9a7563e9 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateLinkServiceConnectionState.Serialization.cs @@ -0,0 +1,167 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// A collection of information about the state of the connection between service consumer and provider. + public partial class MonitorWorkspacesPrivateLinkServiceConnectionState : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MonitorWorkspacesPrivateLinkServiceConnectionState 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 DeserializeMonitorWorkspacesPrivateLinkServiceConnectionState(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MonitorWorkspacesPrivateLinkServiceConnectionState)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(MonitorWorkspacesPrivateLinkServiceConnectionState)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + MonitorWorkspacesPrivateLinkServiceConnectionState IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MonitorWorkspacesPrivateLinkServiceConnectionState)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(ActionsRequired)) + { + writer.WritePropertyName("actionsRequired"u8); + writer.WriteStringValue(ActionsRequired); + } + 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. + MonitorWorkspacesPrivateLinkServiceConnectionState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MonitorWorkspacesPrivateLinkServiceConnectionState 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(MonitorWorkspacesPrivateLinkServiceConnectionState)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMonitorWorkspacesPrivateLinkServiceConnectionState(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MonitorWorkspacesPrivateLinkServiceConnectionState DeserializeMonitorWorkspacesPrivateLinkServiceConnectionState(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MonitorWorkspacesPrivateEndpointServiceConnectionStatus? status = default; + string description = default; + string actionsRequired = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new MonitorWorkspacesPrivateEndpointServiceConnectionStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("actionsRequired"u8)) + { + actionsRequired = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MonitorWorkspacesPrivateLinkServiceConnectionState(status, description, actionsRequired, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateLinkServiceConnectionState.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateLinkServiceConnectionState.cs new file mode 100644 index 000000000000..721a0fac7e69 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/MonitorWorkspacesPrivateLinkServiceConnectionState.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// A collection of information about the state of the connection between service consumer and provider. + public partial class MonitorWorkspacesPrivateLinkServiceConnectionState + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal MonitorWorkspacesPrivateLinkServiceConnectionState() + { + } + + /// Initializes a new instance of . + /// 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 MonitorWorkspacesPrivateLinkServiceConnectionState(MonitorWorkspacesPrivateEndpointServiceConnectionStatus? status, string description, string actionsRequired, IDictionary additionalBinaryDataProperties) + { + Status = status; + Description = description; + ActionsRequired = actionsRequired; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. + public MonitorWorkspacesPrivateEndpointServiceConnectionStatus? Status { get; } + + /// The reason for approval/rejection of the connection. + public string Description { get; } + + /// A message indicating if changes on the service provider require any updates on the consumer. + public string ActionsRequired { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Notifications.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Notifications.Serialization.cs new file mode 100644 index 000000000000..9bf6abb076f9 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Notifications.Serialization.cs @@ -0,0 +1,207 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Issue notification settings. + public partial class Notifications : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Notifications 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 DeserializeNotifications(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Notifications)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(Notifications)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + Notifications IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Notifications)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(UpdateTypes)) + { + writer.WritePropertyName("updateTypes"u8); + writer.WriteStartArray(); + foreach (IssueNotificationType item in UpdateTypes) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ActionGroupIds)) + { + writer.WritePropertyName("actionGroupIds"u8); + writer.WriteStartArray(); + foreach (string item in ActionGroupIds) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ExcludeDefaultActionGroups)) + { + writer.WritePropertyName("excludeDefaultActionGroups"u8); + writer.WriteBooleanValue(ExcludeDefaultActionGroups.Value); + } + 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. + Notifications IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Notifications 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(Notifications)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNotifications(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Notifications DeserializeNotifications(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList updateTypes = default; + IList actionGroupIds = default; + bool? excludeDefaultActionGroups = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("updateTypes"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(IssueNotificationType.DeserializeIssueNotificationType(item, options)); + } + updateTypes = array; + continue; + } + if (prop.NameEquals("actionGroupIds"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()); + } + } + actionGroupIds = array; + continue; + } + if (prop.NameEquals("excludeDefaultActionGroups"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + excludeDefaultActionGroups = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new Notifications(updateTypes ?? new ChangeTrackingList(), actionGroupIds ?? new ChangeTrackingList(), excludeDefaultActionGroups, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Notifications.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Notifications.cs new file mode 100644 index 000000000000..5113f554aa50 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Notifications.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Issue notification settings. + public partial class Notifications + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public Notifications() + { + UpdateTypes = new ChangeTrackingList(); + ActionGroupIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The types of updates that trigger notifications. + /// The action group IDs to notify. + /// Whether to exclude default action groups from notifications. + /// Keeps track of any properties unknown to the library. + internal Notifications(IList updateTypes, IList actionGroupIds, bool? excludeDefaultActionGroups, IDictionary additionalBinaryDataProperties) + { + UpdateTypes = updateTypes; + ActionGroupIds = actionGroupIds; + ExcludeDefaultActionGroups = excludeDefaultActionGroups; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The types of updates that trigger notifications. + public IList UpdateTypes { get; } + + /// The action group IDs to notify. + public IList ActionGroupIds { get; } + + /// Whether to exclude default action groups from notifications. + public bool? ExcludeDefaultActionGroups { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/OnChangeNotificationType.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/OnChangeNotificationType.Serialization.cs new file mode 100644 index 000000000000..1fcf593f7739 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/OnChangeNotificationType.Serialization.cs @@ -0,0 +1,122 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Notification type for on-change events. + public partial class OnChangeNotificationType : IssueNotificationType, IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected override IssueNotificationType 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 DeserializeOnChangeNotificationType(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OnChangeNotificationType)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(OnChangeNotificationType)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + OnChangeNotificationType IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (OnChangeNotificationType)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OnChangeNotificationType)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + OnChangeNotificationType IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (OnChangeNotificationType)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override IssueNotificationType 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(OnChangeNotificationType)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOnChangeNotificationType(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OnChangeNotificationType DeserializeOnChangeNotificationType(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UpdateType updateType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("updateType"u8)) + { + updateType = new UpdateType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OnChangeNotificationType(updateType, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/OnChangeNotificationType.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/OnChangeNotificationType.cs new file mode 100644 index 000000000000..d5063145955a --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/OnChangeNotificationType.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Notification type for on-change events. + public partial class OnChangeNotificationType : IssueNotificationType + { + /// Initializes a new instance of . + public OnChangeNotificationType() : base(UpdateType.OnChange) + { + } + + /// Initializes a new instance of . + /// The type of update that triggers the notification. + /// Keeps track of any properties unknown to the library. + internal OnChangeNotificationType(UpdateType updateType, IDictionary additionalBinaryDataProperties) : base(updateType, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Origin.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Origin.Serialization.cs new file mode 100644 index 000000000000..bad208a4076d --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Origin.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Details about the origin of the entity - the source that added it to the issue. + internal partial class Origin : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal Origin() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Models.Origin 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 Models.Origin.DeserializeOrigin(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Models.Origin)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(Models.Origin)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + Models.Origin IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Models.Origin)} does not support writing '{format}' format."); + } + writer.WritePropertyName("addedBy"u8); + writer.WriteStringValue(AddedBy); + writer.WritePropertyName("addedByType"u8); + writer.WriteStringValue(AddedByType.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. + Models.Origin IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Models.Origin 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(Models.Origin)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return Models.Origin.DeserializeOrigin(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Models.Origin DeserializeOrigin(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string addedBy = default; + AddedByType addedByType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("addedBy"u8)) + { + addedBy = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("addedByType"u8)) + { + addedByType = new AddedByType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new Models.Origin(addedBy, addedByType, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Origin.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Origin.cs new file mode 100644 index 000000000000..ae9598b281d8 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Origin.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Details about the origin of the entity - the source that added it to the issue. + internal partial class Origin + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The ID of the origin - for example, in case of 'Manual', the user ID/app ID, and in case of 'Automatic', the name of the automatic system. + /// The source of the origin - Manual or Automatic. + /// is null. + public Origin(string addedBy, AddedByType addedByType) + { + Argument.AssertNotNull(addedBy, nameof(addedBy)); + + AddedBy = addedBy; + AddedByType = addedByType; + } + + /// Initializes a new instance of . + /// The ID of the origin - for example, in case of 'Manual', the user ID/app ID, and in case of 'Automatic', the name of the automatic system. + /// The source of the origin - Manual or Automatic. + /// Keeps track of any properties unknown to the library. + internal Origin(string addedBy, AddedByType addedByType, IDictionary additionalBinaryDataProperties) + { + AddedBy = addedBy; + AddedByType = addedByType; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The ID of the origin - for example, in case of 'Manual', the user ID/app ID, and in case of 'Automatic', the name of the automatic system. + public string AddedBy { get; set; } + + /// The source of the origin - Manual or Automatic. + public AddedByType AddedByType { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PagedRelatedAlert.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PagedRelatedAlert.Serialization.cs new file mode 100644 index 000000000000..bcec52a41499 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PagedRelatedAlert.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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Paged collection of RelatedAlert items. + public partial class PagedRelatedAlert : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedRelatedAlert() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedRelatedAlert 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 DeserializePagedRelatedAlert(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedRelatedAlert)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(PagedRelatedAlert)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + PagedRelatedAlert IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static PagedRelatedAlert FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedRelatedAlert(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedRelatedAlert)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (RelatedAlert 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. + PagedRelatedAlert IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedRelatedAlert 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(PagedRelatedAlert)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedRelatedAlert(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedRelatedAlert DeserializePagedRelatedAlert(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(RelatedAlert.DeserializeRelatedAlert(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedRelatedAlert(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PagedRelatedAlert.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PagedRelatedAlert.cs new file mode 100644 index 000000000000..64195bf32112 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PagedRelatedAlert.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Paged collection of RelatedAlert items. + public partial class PagedRelatedAlert + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The RelatedAlert items on this page. + internal PagedRelatedAlert(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The RelatedAlert items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal PagedRelatedAlert(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The RelatedAlert items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PagedRelatedResource.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PagedRelatedResource.Serialization.cs new file mode 100644 index 000000000000..3475b68e89fd --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PagedRelatedResource.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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Paged collection of RelatedResource items. + public partial class PagedRelatedResource : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedRelatedResource() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedRelatedResource 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 DeserializePagedRelatedResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedRelatedResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(PagedRelatedResource)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + PagedRelatedResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static PagedRelatedResource FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedRelatedResource(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedRelatedResource)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (RelatedResource 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. + PagedRelatedResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedRelatedResource 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(PagedRelatedResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedRelatedResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedRelatedResource DeserializePagedRelatedResource(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(RelatedResource.DeserializeRelatedResource(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedRelatedResource(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PagedRelatedResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PagedRelatedResource.cs new file mode 100644 index 000000000000..17970b5cd331 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PagedRelatedResource.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Paged collection of RelatedResource items. + public partial class PagedRelatedResource + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The RelatedResource items on this page. + internal PagedRelatedResource(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The RelatedResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal PagedRelatedResource(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The RelatedResource items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PrivateEndpoint.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PrivateEndpoint.Serialization.cs new file mode 100644 index 000000000000..71d2cc20d79e --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PrivateEndpoint.Serialization.cs @@ -0,0 +1,146 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The private endpoint resource. + internal partial class PrivateEndpoint : IJsonModel + { + /// 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. + 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, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(PrivateEndpoint)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + PrivateEndpoint IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(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; + } + ResourceIdentifier id = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PrivateEndpoint(id, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PrivateEndpoint.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PrivateEndpoint.cs new file mode 100644 index 000000000000..09ef703ee82a --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PrivateEndpoint.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Monitor.Workspaces.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 . + internal PrivateEndpoint() + { + } + + /// Initializes a new instance of . + /// The resource identifier of the private endpoint. + /// Keeps track of any properties unknown to the library. + internal PrivateEndpoint(ResourceIdentifier id, IDictionary additionalBinaryDataProperties) + { + Id = id; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The resource identifier of the private endpoint. + public ResourceIdentifier Id { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PrivateEndpointConnectionProperties.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PrivateEndpointConnectionProperties.Serialization.cs new file mode 100644 index 000000000000..db92f2d64c57 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Properties of the private endpoint connection. + public partial class PrivateEndpointConnectionProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PrivateEndpointConnectionProperties() + { + } + + /// 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. + 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, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(PrivateEndpointConnectionProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + PrivateEndpointConnectionProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PrivateEndpointConnectionProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && 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(PrivateEndpoint)) + { + writer.WritePropertyName("privateEndpoint"u8); + writer.WriteObjectValue(PrivateEndpoint, options); + } + writer.WritePropertyName("privateLinkServiceConnectionState"u8); + writer.WriteObjectValue(PrivateLinkServiceConnectionState, options); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + 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; + } + IReadOnlyList groupIds = default; + PrivateEndpoint privateEndpoint = default; + MonitorWorkspacesPrivateLinkServiceConnectionState privateLinkServiceConnectionState = default; + MonitorWorkspacesPrivateEndpointConnectionProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + 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("privateEndpoint"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateEndpoint = PrivateEndpoint.DeserializePrivateEndpoint(prop.Value, options); + continue; + } + if (prop.NameEquals("privateLinkServiceConnectionState"u8)) + { + privateLinkServiceConnectionState = MonitorWorkspacesPrivateLinkServiceConnectionState.DeserializeMonitorWorkspacesPrivateLinkServiceConnectionState(prop.Value, options); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new MonitorWorkspacesPrivateEndpointConnectionProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PrivateEndpointConnectionProperties(groupIds ?? new ChangeTrackingList(), privateEndpoint, privateLinkServiceConnectionState, provisioningState, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PrivateEndpointConnectionProperties.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PrivateEndpointConnectionProperties.cs new file mode 100644 index 000000000000..14e4750f05a8 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PrivateEndpointConnectionProperties.cs @@ -0,0 +1,65 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Properties of the private endpoint connection. + public 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. + internal PrivateEndpointConnectionProperties(MonitorWorkspacesPrivateLinkServiceConnectionState privateLinkServiceConnectionState) + { + GroupIds = new ChangeTrackingList(); + PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; + } + + /// Initializes a new instance of . + /// The group ids for the private endpoint resource. + /// The private endpoint resource. + /// A collection of information about the state of the connection between service consumer and provider. + /// The provisioning state of the private endpoint connection resource. + /// Keeps track of any properties unknown to the library. + internal PrivateEndpointConnectionProperties(IReadOnlyList groupIds, PrivateEndpoint privateEndpoint, MonitorWorkspacesPrivateLinkServiceConnectionState privateLinkServiceConnectionState, MonitorWorkspacesPrivateEndpointConnectionProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + GroupIds = groupIds; + PrivateEndpoint = privateEndpoint; + PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The group ids for the private endpoint resource. + public IReadOnlyList GroupIds { get; } + + /// The private endpoint resource. + internal PrivateEndpoint PrivateEndpoint { get; } + + /// A collection of information about the state of the connection between service consumer and provider. + public MonitorWorkspacesPrivateLinkServiceConnectionState PrivateLinkServiceConnectionState { get; } + + /// The provisioning state of the private endpoint connection resource. + public MonitorWorkspacesPrivateEndpointConnectionProvisioningState? ProvisioningState { get; } + + /// The resource identifier of the private endpoint. + public ResourceIdentifier PrivateEndpointId + { + get + { + return PrivateEndpoint is null ? default : PrivateEndpoint.Id; + } + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PublicNetworkAccess.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PublicNetworkAccess.cs new file mode 100644 index 000000000000..238cae5a72ec --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/PublicNetworkAccess.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Gets or sets allow or disallow public network access to Azure Monitor Workspace. + public readonly partial struct PublicNetworkAccess : IEquatable + { + private readonly string _value; + /// Public network access is enabled. + private const string EnabledValue = "Enabled"; + /// Public network access is disabled. + private const string DisabledValue = "Disabled"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public PublicNetworkAccess(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Public network access is enabled. + public static PublicNetworkAccess Enabled { get; } = new PublicNetworkAccess(EnabledValue); + + /// Public network access is disabled. + public static PublicNetworkAccess Disabled { get; } = new PublicNetworkAccess(DisabledValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(PublicNetworkAccess left, PublicNetworkAccess 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 !=(PublicNetworkAccess left, PublicNetworkAccess right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator PublicNetworkAccess(string value) => new PublicNetworkAccess(value); + + /// Converts a string to a . + /// The value. + public static implicit operator PublicNetworkAccess?(string value) => value == null ? null : new PublicNetworkAccess(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PublicNetworkAccess other && Equals(other); + + /// + public bool Equals(PublicNetworkAccess 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedAlert.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedAlert.Serialization.cs new file mode 100644 index 000000000000..ef837f583454 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedAlert.Serialization.cs @@ -0,0 +1,191 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Properties of an alert which is related to the issue. + public partial class RelatedAlert : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal RelatedAlert() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RelatedAlert 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 DeserializeRelatedAlert(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RelatedAlert)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(RelatedAlert)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + RelatedAlert IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RelatedAlert)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("relevance"u8); + writer.WriteStringValue(Relevance.ToString()); + if (options.Format != "W") + { + writer.WritePropertyName("origin"u8); + writer.WriteObjectValue(Origin, options); + } + if (options.Format != "W") + { + writer.WritePropertyName("addedAt"u8); + writer.WriteStringValue(AddedOn, "O"); + } + if (options.Format != "W") + { + writer.WritePropertyName("lastModifiedAt"u8); + writer.WriteStringValue(LastModifiedOn, "O"); + } + 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. + RelatedAlert IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RelatedAlert 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(RelatedAlert)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRelatedAlert(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RelatedAlert DeserializeRelatedAlert(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + Relevance relevance = default; + Models.Origin origin = default; + DateTimeOffset addedOn = default; + DateTimeOffset lastModifiedOn = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("relevance"u8)) + { + relevance = new Relevance(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("origin"u8)) + { + origin = Models.Origin.DeserializeOrigin(prop.Value, options); + continue; + } + if (prop.NameEquals("addedAt"u8)) + { + addedOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("lastModifiedAt"u8)) + { + lastModifiedOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new RelatedAlert( + id, + relevance, + origin, + addedOn, + lastModifiedOn, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedAlert.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedAlert.cs new file mode 100644 index 000000000000..5bbea67e5e5d --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedAlert.cs @@ -0,0 +1,65 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Properties of an alert which is related to the issue. + public partial class RelatedAlert + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The alert ID. + /// The alerts's relevance status. + /// is null. + public RelatedAlert(ResourceIdentifier id, Relevance relevance) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + Relevance = relevance; + } + + /// Initializes a new instance of . + /// The alert ID. + /// The alerts's relevance status. + /// The source that related the alert to the issue. + /// The time this relation was added to the issue (in UTC). + /// The last update time of this relation (in UTC). + /// Keeps track of any properties unknown to the library. + internal RelatedAlert(ResourceIdentifier id, Relevance relevance, Models.Origin origin, DateTimeOffset addedOn, DateTimeOffset lastModifiedOn, IDictionary additionalBinaryDataProperties) + { + Id = id; + Relevance = relevance; + Origin = origin; + AddedOn = addedOn; + LastModifiedOn = lastModifiedOn; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The alert ID. + public ResourceIdentifier Id { get; set; } + + /// The alerts's relevance status. + public Relevance Relevance { get; set; } + + /// The source that related the alert to the issue. + public Models.Origin Origin { get; } + + /// The time this relation was added to the issue (in UTC). + public DateTimeOffset AddedOn { get; } + + /// The last update time of this relation (in UTC). + public DateTimeOffset LastModifiedOn { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedAlerts.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedAlerts.Serialization.cs new file mode 100644 index 000000000000..bfbc48c66f50 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedAlerts.Serialization.cs @@ -0,0 +1,172 @@ +// 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.Core; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// A list of related alerts. + public partial class RelatedAlerts : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal RelatedAlerts() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RelatedAlerts 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 DeserializeRelatedAlerts(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RelatedAlerts)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(RelatedAlerts)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + RelatedAlerts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(RelatedAlerts relatedAlerts) + { + if (relatedAlerts == null) + { + return null; + } + return RequestContent.Create(relatedAlerts, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static RelatedAlerts FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRelatedAlerts(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RelatedAlerts)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (RelatedAlert item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + RelatedAlerts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RelatedAlerts 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(RelatedAlerts)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRelatedAlerts(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RelatedAlerts DeserializeRelatedAlerts(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = 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(RelatedAlert.DeserializeRelatedAlert(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new RelatedAlerts(value, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedAlerts.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedAlerts.cs new file mode 100644 index 000000000000..3725e4412636 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedAlerts.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 System.Linq; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// A list of related alerts. + public partial class RelatedAlerts + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// A list of related alerts. + /// is null. + public RelatedAlerts(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// A list of related alerts. + /// Keeps track of any properties unknown to the library. + internal RelatedAlerts(IList value, IDictionary additionalBinaryDataProperties) + { + Value = value; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// A list of related alerts. + public IList Value { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedResource.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedResource.Serialization.cs new file mode 100644 index 000000000000..c30258696e8a --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedResource.Serialization.cs @@ -0,0 +1,191 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Properties of a resource which is related to the issue. + public partial class RelatedResource : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal RelatedResource() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RelatedResource 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 DeserializeRelatedResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RelatedResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(RelatedResource)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + RelatedResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RelatedResource)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("relevance"u8); + writer.WriteStringValue(Relevance.ToString()); + if (options.Format != "W") + { + writer.WritePropertyName("origin"u8); + writer.WriteObjectValue(Origin, options); + } + if (options.Format != "W") + { + writer.WritePropertyName("addedAt"u8); + writer.WriteStringValue(AddedOn, "O"); + } + if (options.Format != "W") + { + writer.WritePropertyName("lastModifiedAt"u8); + writer.WriteStringValue(LastModifiedOn, "O"); + } + 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. + RelatedResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RelatedResource 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(RelatedResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRelatedResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RelatedResource DeserializeRelatedResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + Relevance relevance = default; + Models.Origin origin = default; + DateTimeOffset addedOn = default; + DateTimeOffset lastModifiedOn = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("relevance"u8)) + { + relevance = new Relevance(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("origin"u8)) + { + origin = Models.Origin.DeserializeOrigin(prop.Value, options); + continue; + } + if (prop.NameEquals("addedAt"u8)) + { + addedOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("lastModifiedAt"u8)) + { + lastModifiedOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new RelatedResource( + id, + relevance, + origin, + addedOn, + lastModifiedOn, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedResource.cs new file mode 100644 index 000000000000..84fa65323e6d --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedResource.cs @@ -0,0 +1,65 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Properties of a resource which is related to the issue. + public partial class RelatedResource + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The resource ID. + /// The resource's relevance status. + /// is null. + public RelatedResource(ResourceIdentifier id, Relevance relevance) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + Relevance = relevance; + } + + /// Initializes a new instance of . + /// The resource ID. + /// The resource's relevance status. + /// The source that related the resource to the issue. + /// The time this relation was added to the issue (in UTC). + /// The last update time of this relation (in UTC). + /// Keeps track of any properties unknown to the library. + internal RelatedResource(ResourceIdentifier id, Relevance relevance, Models.Origin origin, DateTimeOffset addedOn, DateTimeOffset lastModifiedOn, IDictionary additionalBinaryDataProperties) + { + Id = id; + Relevance = relevance; + Origin = origin; + AddedOn = addedOn; + LastModifiedOn = lastModifiedOn; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The resource ID. + public ResourceIdentifier Id { get; set; } + + /// The resource's relevance status. + public Relevance Relevance { get; set; } + + /// The source that related the resource to the issue. + public Models.Origin Origin { get; } + + /// The time this relation was added to the issue (in UTC). + public DateTimeOffset AddedOn { get; } + + /// The last update time of this relation (in UTC). + public DateTimeOffset LastModifiedOn { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedResources.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedResources.Serialization.cs new file mode 100644 index 000000000000..abc0c029d862 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedResources.Serialization.cs @@ -0,0 +1,172 @@ +// 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.Core; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// A list of related resources. + public partial class RelatedResources : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal RelatedResources() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RelatedResources 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 DeserializeRelatedResources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RelatedResources)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(RelatedResources)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + RelatedResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(RelatedResources relatedResources) + { + if (relatedResources == null) + { + return null; + } + return RequestContent.Create(relatedResources, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static RelatedResources FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRelatedResources(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RelatedResources)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (RelatedResource item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + RelatedResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RelatedResources 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(RelatedResources)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRelatedResources(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RelatedResources DeserializeRelatedResources(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = 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(RelatedResource.DeserializeRelatedResource(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new RelatedResources(value, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedResources.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedResources.cs new file mode 100644 index 000000000000..25581b8a00ad --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/RelatedResources.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 System.Linq; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// A list of related resources. + public partial class RelatedResources + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// A list of related resources. + /// is null. + public RelatedResources(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// A list of related resources. + /// Keeps track of any properties unknown to the library. + internal RelatedResources(IList value, IDictionary additionalBinaryDataProperties) + { + Value = value; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// A list of related resources. + public IList Value { get; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Relevance.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Relevance.cs new file mode 100644 index 000000000000..ed3ab1f1f5f7 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Relevance.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The relevance status of the resource. + public readonly partial struct Relevance : IEquatable + { + private readonly string _value; + /// No relevance status for the resource. + private const string NoneValue = "None"; + /// The resource is relevant to the issue. + private const string RelevantValue = "Relevant"; + /// The resource is irrelevant to the issue. + private const string IrrelevantValue = "Irrelevant"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public Relevance(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// No relevance status for the resource. + public static Relevance None { get; } = new Relevance(NoneValue); + + /// The resource is relevant to the issue. + public static Relevance Relevant { get; } = new Relevance(RelevantValue); + + /// The resource is irrelevant to the issue. + public static Relevance Irrelevant { get; } = new Relevance(IrrelevantValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(Relevance left, Relevance 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 !=(Relevance left, Relevance right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator Relevance(string value) => new Relevance(value); + + /// Converts a string to a . + /// The value. + public static implicit operator Relevance?(string value) => value == null ? null : new Relevance(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Relevance other && Equals(other); + + /// + public bool Equals(Relevance 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/ResourceProvisioningState.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/ResourceProvisioningState.cs new file mode 100644 index 000000000000..ce4762e5b9a3 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/ResourceProvisioningState.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The provisioning state of a resource type. + public readonly partial struct ResourceProvisioningState : IEquatable + { + private readonly string _value; + /// Resource has been created. + private const string SucceededValue = "Succeeded"; + /// Resource creation failed. + private const string FailedValue = "Failed"; + /// Resource creation was canceled. + private const string CanceledValue = "Canceled"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ResourceProvisioningState(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Resource has been created. + public static ResourceProvisioningState Succeeded { get; } = new ResourceProvisioningState(SucceededValue); + + /// Resource creation failed. + public static ResourceProvisioningState Failed { get; } = new ResourceProvisioningState(FailedValue); + + /// Resource creation was canceled. + public static ResourceProvisioningState Canceled { get; } = new ResourceProvisioningState(CanceledValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ResourceProvisioningState left, ResourceProvisioningState 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 !=(ResourceProvisioningState left, ResourceProvisioningState right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ResourceProvisioningState(string value) => new ResourceProvisioningState(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ResourceProvisioningState?(string value) => value == null ? null : new ResourceProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResourceProvisioningState other && Equals(other); + + /// + public bool Equals(ResourceProvisioningState 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Status.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Status.cs new file mode 100644 index 000000000000..40f7bf82c551 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/Status.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The issue status. + public readonly partial struct Status : IEquatable + { + private readonly string _value; + /// The issue is new. + private const string NewValue = "New"; + /// The issue is in progress. + private const string InProgressValue = "InProgress"; + /// The issue is mitigated. + private const string MitigatedValue = "Mitigated"; + /// The issue is closed. + private const string ClosedValue = "Closed"; + /// The issue is canceled. + private const string CanceledValue = "Canceled"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public Status(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// The issue is new. + public static Status New { get; } = new Status(NewValue); + + /// The issue is in progress. + public static Status InProgress { get; } = new Status(InProgressValue); + + /// The issue is mitigated. + public static Status Mitigated { get; } = new Status(MitigatedValue); + + /// The issue is closed. + public static Status Closed { get; } = new Status(ClosedValue); + + /// The issue is canceled. + public static Status Canceled { get; } = new Status(CanceledValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(Status left, Status 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 !=(Status left, Status right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator Status(string value) => new Status(value); + + /// Converts a string to a . + /// The value. + public static implicit operator Status?(string value) => value == null ? null : new Status(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Status other && Equals(other); + + /// + public bool Equals(Status 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/TimeBasedUpdatesNotificationType.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/TimeBasedUpdatesNotificationType.Serialization.cs new file mode 100644 index 000000000000..ccdf4dbf9254 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/TimeBasedUpdatesNotificationType.Serialization.cs @@ -0,0 +1,135 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Notification type for time-based updates. + public partial class TimeBasedUpdatesNotificationType : IssueNotificationType, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal TimeBasedUpdatesNotificationType() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override IssueNotificationType 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 DeserializeTimeBasedUpdatesNotificationType(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TimeBasedUpdatesNotificationType)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(TimeBasedUpdatesNotificationType)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TimeBasedUpdatesNotificationType IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TimeBasedUpdatesNotificationType)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TimeBasedUpdatesNotificationType)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("updateInterval"u8); + writer.WriteStringValue(UpdateInterval); + } + + /// The JSON reader. + /// The client options for reading and writing models. + TimeBasedUpdatesNotificationType IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TimeBasedUpdatesNotificationType)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override IssueNotificationType 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(TimeBasedUpdatesNotificationType)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTimeBasedUpdatesNotificationType(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TimeBasedUpdatesNotificationType DeserializeTimeBasedUpdatesNotificationType(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UpdateType updateType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string updateInterval = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("updateType"u8)) + { + updateType = new UpdateType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("updateInterval"u8)) + { + updateInterval = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TimeBasedUpdatesNotificationType(updateType, additionalBinaryDataProperties, updateInterval); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/TimeBasedUpdatesNotificationType.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/TimeBasedUpdatesNotificationType.cs new file mode 100644 index 000000000000..4616b09ad3e1 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/TimeBasedUpdatesNotificationType.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// Notification type for time-based updates. + public partial class TimeBasedUpdatesNotificationType : IssueNotificationType + { + /// Initializes a new instance of . + /// The interval between time-based updates. + /// is null. + public TimeBasedUpdatesNotificationType(string updateInterval) : base(UpdateType.TimeBased) + { + Argument.AssertNotNull(updateInterval, nameof(updateInterval)); + + UpdateInterval = updateInterval; + } + + /// Initializes a new instance of . + /// The type of update that triggers the notification. + /// Keeps track of any properties unknown to the library. + /// The interval between time-based updates. + internal TimeBasedUpdatesNotificationType(UpdateType updateType, IDictionary additionalBinaryDataProperties, string updateInterval) : base(updateType, additionalBinaryDataProperties) + { + UpdateInterval = updateInterval; + } + + /// The interval between time-based updates. + public string UpdateInterval { get; set; } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/UnknownIssueNotificationType.Serialization.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/UnknownIssueNotificationType.Serialization.cs new file mode 100644 index 000000000000..0ac0da2036e9 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/UnknownIssueNotificationType.Serialization.cs @@ -0,0 +1,126 @@ +// 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.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + internal partial class UnknownIssueNotificationType : IssueNotificationType, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownIssueNotificationType() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override IssueNotificationType 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 DeserializeIssueNotificationType(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IssueNotificationType)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerMonitorWorkspacesContext.Default); + default: + throw new FormatException($"The model {nameof(IssueNotificationType)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + IssueNotificationType IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected 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(IssueNotificationType)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + IssueNotificationType IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override IssueNotificationType 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(IssueNotificationType)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIssueNotificationType(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownIssueNotificationType DeserializeUnknownIssueNotificationType(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UpdateType updateType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("updateType"u8)) + { + updateType = new UpdateType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownIssueNotificationType(updateType, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/UnknownIssueNotificationType.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/UnknownIssueNotificationType.cs new file mode 100644 index 000000000000..66ff14eda59a --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/UnknownIssueNotificationType.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + internal partial class UnknownIssueNotificationType : IssueNotificationType + { + /// Initializes a new instance of . + /// The type of update that triggers the notification. + /// Keeps track of any properties unknown to the library. + internal UnknownIssueNotificationType(UpdateType updateType, IDictionary additionalBinaryDataProperties) : base(updateType != default ? updateType : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/UpdateType.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/UpdateType.cs new file mode 100644 index 000000000000..dc742a460d08 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/Models/UpdateType.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Monitor.Workspaces; + +namespace Azure.ResourceManager.Monitor.Workspaces.Models +{ + /// The type of update that triggers a notification. + internal readonly partial struct UpdateType : IEquatable + { + private readonly string _value; + /// Notification sent when an issue is created. + private const string IssueCreationValue = "IssueCreation"; + /// Notification sent based on time intervals. + private const string TimeBasedValue = "TimeBased"; + /// Notification sent when the issue changes. + private const string OnChangeValue = "OnChange"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public UpdateType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Notification sent when an issue is created. + public static UpdateType IssueCreation { get; } = new UpdateType(IssueCreationValue); + + /// Notification sent based on time intervals. + public static UpdateType TimeBased { get; } = new UpdateType(TimeBasedValue); + + /// Notification sent when the issue changes. + public static UpdateType OnChange { get; } = new UpdateType(OnChangeValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(UpdateType left, UpdateType 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 !=(UpdateType left, UpdateType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator UpdateType(string value) => new UpdateType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator UpdateType?(string value) => value == null ? null : new UpdateType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is UpdateType other && Equals(other); + + /// + public bool Equals(UpdateType 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/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/ProviderConstants.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..2aaa56c1151e --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/ProviderConstants.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal static partial class ProviderConstants + { + /// Gets the DefaultProviderNamespace. + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/RestOperations/AzureMonitorWorkspacesRestOperations.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/RestOperations/AzureMonitorWorkspacesRestOperations.cs new file mode 100644 index 000000000000..e5108a747719 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/RestOperations/AzureMonitorWorkspacesRestOperations.cs @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Monitor.Workspaces +{ + internal partial class AzureMonitorWorkspaces + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of AzureMonitorWorkspaces for mocking. + protected AzureMonitorWorkspaces() + { + } + + /// Initializes a new instance of AzureMonitorWorkspaces. + /// 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 AzureMonitorWorkspaces(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetByResourceGroupRequest(Guid subscriptionId, string resourceGroupName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetByResourceGroupRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetBySubscriptionRequest(Guid subscriptionId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetBySubscriptionRequest(Uri nextPage, Guid subscriptionId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/RestOperations/IssueRestOperations.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/RestOperations/IssueRestOperations.cs new file mode 100644 index 000000000000..213a90edadb4 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/RestOperations/IssueRestOperations.cs @@ -0,0 +1,406 @@ +// 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.Monitor.Workspaces +{ + internal partial class Issue + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Issue for mocking. + protected Issue() + { + } + + /// Initializes a new instance of Issue. + /// 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 Issue(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 CreateCreateRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string issueName, RequestContent content, string related, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/issues/", false); + uri.AppendPath(issueName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + if (related != null) + { + uri.AppendQuery("related", related, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string issueName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/issues/", false); + uri.AppendPath(issueName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string issueName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/issues/", false); + uri.AppendPath(issueName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string issueName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/issues/", false); + uri.AppendPath(issueName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetAllRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/issues", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateAddInvestigationResultRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string issueName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/issues/", false); + uri.AppendPath(issueName, true); + uri.AppendPath("/addInvestigationResult", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateFetchInvestigationResultRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string issueName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/issues/", false); + uri.AppendPath(issueName, true); + uri.AppendPath("/fetchInvestigationResult", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAlertsRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string issueName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/issues/", false); + uri.AppendPath(issueName, true); + uri.AppendPath("/listAlerts", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateAddOrUpdateAlertsRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string issueName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/issues/", false); + uri.AppendPath(issueName, true); + uri.AppendPath("/addOrUpdateAlerts", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetResourcesRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string issueName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/issues/", false); + uri.AppendPath(issueName, true); + uri.AppendPath("/listResources", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateAddOrUpdateResourcesRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string issueName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/issues/", false); + uri.AppendPath(issueName, true); + uri.AppendPath("/addOrUpdateResources", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateFetchBackgroundVisualizationRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string issueName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/issues/", false); + uri.AppendPath(issueName, true); + uri.AppendPath("/fetchBackgroundVisualization", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateSetBackgroundVisualizationRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string issueName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/issues/", false); + uri.AppendPath(issueName, true); + uri.AppendPath("/setBackgroundVisualization", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Content = content; + return message; + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/RestOperations/MetricsContainersRestOperations.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/RestOperations/MetricsContainersRestOperations.cs new file mode 100644 index 000000000000..c540672a4181 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Generated/RestOperations/MetricsContainersRestOperations.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.Monitor.Workspaces +{ + internal partial class MetricsContainers + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of MetricsContainers for mocking. + protected MetricsContainers() + { + } + + /// Initializes a new instance of MetricsContainers. + /// 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 MetricsContainers(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string metricsContainerName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/metricsContainers/", false); + uri.AppendPath(metricsContainerName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, string metricsContainerName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/metricsContainers/", false); + uri.AppendPath(metricsContainerName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetByAzureMonitorWorkspaceRequest(Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Monitor/accounts/", false); + uri.AppendPath(azureMonitorWorkspaceName, true); + uri.AppendPath("/metricsContainers", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetByAzureMonitorWorkspaceRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string azureMonitorWorkspaceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Properties/AssemblyInfo.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..896c0d84a2d5 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/src/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Monitor.Workspaces")] + +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] +[assembly: InternalsVisibleTo("Azure.ResourceManager.Monitor.Workspaces.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/tests/Azure.ResourceManager.Monitor.Workspaces.Tests.csproj b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/tests/Azure.ResourceManager.Monitor.Workspaces.Tests.csproj new file mode 100644 index 000000000000..f46e287134e1 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/tests/Azure.ResourceManager.Monitor.Workspaces.Tests.csproj @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/tests/WorkspacesManagementTestBase.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/tests/WorkspacesManagementTestBase.cs new file mode 100644 index 000000000000..66f49a3e65d6 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/tests/WorkspacesManagementTestBase.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.Monitor.Workspaces.Tests +{ + public class WorkspacesManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected WorkspacesManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected WorkspacesManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + } + + protected async Task CreateResourceGroup(SubscriptionResource subscription, string rgNamePrefix, AzureLocation location) + { + string rgName = Recording.GenerateAssetName(rgNamePrefix); + ResourceGroupData input = new ResourceGroupData(location); + var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, input); + return lro.Value; + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/tests/WorkspacesManagementTestEnvironment.cs b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/tests/WorkspacesManagementTestEnvironment.cs new file mode 100644 index 000000000000..cf22ed923b2e --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/tests/WorkspacesManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.Monitor.Workspaces.Tests +{ + public class WorkspacesManagementTestEnvironment : TestEnvironment + { + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/tsp-location.yaml b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/tsp-location.yaml new file mode 100644 index 000000000000..a9387f461682 --- /dev/null +++ b/sdk/monitor/Azure.ResourceManager.Monitor.Workspaces/tsp-location.yaml @@ -0,0 +1,6 @@ +directory: specification/monitoringservice/resource-manager/Microsoft.Monitor/Accounts +commit: b26c3c253cff26dd05361e882dbcf1b324f27dfd +repo: Azure/azure-rest-api-specs +additionalDirectories: + +emitterPackageJsonPath: eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json \ No newline at end of file diff --git a/sdk/monitor/ci.mgmt.yml b/sdk/monitor/ci.mgmt.yml index 4f74edd0e221..251fd205553b 100644 --- a/sdk/monitor/ci.mgmt.yml +++ b/sdk/monitor/ci.mgmt.yml @@ -9,6 +9,8 @@ extends: ServiceDirectory: monitor LimitForPullRequest: true Artifacts: + - name: Azure.ResourceManager.Monitor.Workspaces + safeName: AzureResourceManagerMonitorWorkspaces - name: Azure.ResourceManager.Monitor safeName: AzureResourceManagerMonitor - name: Azure.ResourceManager.Monitor.Slis