Skip to content

Commit

Permalink
Add operational insights resource (#42744)
Browse files Browse the repository at this point in the history
* Add operational insights resource

* fix test and cspell false positive

* pr fb
  • Loading branch information
JoshLove-msft authored Mar 15, 2024
1 parent 3928f09 commit 9463d82
Show file tree
Hide file tree
Showing 39 changed files with 142 additions and 30 deletions.
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"nunit",
"odata",
"onco",
"opinsights",
"otel",
"overridden",
"parallelization",
Expand Down
1 change: 1 addition & 0 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
<PackageReference Update="Azure.ResourceManager.CosmosDB" Version="1.4.0-alpha.20240309.1" />
<PackageReference Update="Azure.ResourceManager.EventHubs" Version="1.1.0-alpha.20240311.3" />
<PackageReference Update="Azure.ResourceManager.KeyVault" Version="1.3.0-alpha.20240310.2" />
<PackageReference Update="Azure.ResourceManager.OperationalInsights" Version="1.3.0-alpha.20240315.1" />
<PackageReference Update="Azure.ResourceManager.PostgreSql" Version="1.2.0-alpha.20240309.1" />
<PackageReference Update="Azure.ResourceManager.Redis" Version="1.4.0-alpha.20240309.1" />
<PackageReference Update="Azure.ResourceManager.Resources" Version="1.8.0-alpha.20240309.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ public partial class KeyVaultSecret : Azure.Provisioning.Resource<Azure.Resource
public static Azure.Provisioning.KeyVaults.KeyVaultSecret FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.KeyVaults.KeyVault parent) { throw null; }
}
}
namespace Azure.Provisioning.OperationalInsights
{
public partial class OperationalInsightsWorkspace : Azure.Provisioning.Resource<Azure.ResourceManager.OperationalInsights.OperationalInsightsWorkspaceData>
{
public OperationalInsightsWorkspace(Azure.Provisioning.IConstruct scope, Azure.ResourceManager.OperationalInsights.Models.OperationalInsightsWorkspaceSku? sku = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "opinsights", string version = "2022-10-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func<string, Azure.ResourceManager.OperationalInsights.OperationalInsightsWorkspaceData>)) { }
public static Azure.Provisioning.OperationalInsights.OperationalInsightsWorkspace FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; }
protected override string GetAzureName(Azure.Provisioning.IConstruct scope, string resourceName) { throw null; }
}
}
namespace Azure.Provisioning.PostgreSql
{
public partial class PostgreSqlConnectionString : Azure.Provisioning.ConnectionString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ public partial class KeyVaultSecret : Azure.Provisioning.Resource<Azure.Resource
public static Azure.Provisioning.KeyVaults.KeyVaultSecret FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.KeyVaults.KeyVault parent) { throw null; }
}
}
namespace Azure.Provisioning.OperationalInsights
{
public partial class OperationalInsightsWorkspace : Azure.Provisioning.Resource<Azure.ResourceManager.OperationalInsights.OperationalInsightsWorkspaceData>
{
public OperationalInsightsWorkspace(Azure.Provisioning.IConstruct scope, Azure.ResourceManager.OperationalInsights.Models.OperationalInsightsWorkspaceSku? sku = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "opinsights", string version = "2022-10-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func<string, Azure.ResourceManager.OperationalInsights.OperationalInsightsWorkspaceData>)) { }
public static Azure.Provisioning.OperationalInsights.OperationalInsightsWorkspace FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; }
protected override string GetAzureName(Azure.Provisioning.IConstruct scope, string resourceName) { throw null; }
}
}
namespace Azure.Provisioning.PostgreSql
{
public partial class PostgreSqlConnectionString : Azure.Provisioning.ConnectionString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<PackageReference Include="Azure.ResourceManager.EventHubs" />
<PackageReference Include="Azure.ResourceManager.SignalR" />
<PackageReference Include="Azure.ResourceManager.ApplicationInsights" />
<PackageReference Include="Azure.ResourceManager.OperationalInsights" />
<PackageReference Include="System.ClientModel" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class AppConfigurationStore : Resource<AppConfigurationStoreData>
// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/RestOperations/ConfigurationStoresRestOperations.cs#L36
private const string DefaultVersion = "2023-03-01";

private static readonly Func<string, AppConfigurationStoreData> Empty = (name) => ArmAppConfigurationModelFactory.AppConfigurationStoreData();
private static AppConfigurationStoreData Empty(string name) => ArmAppConfigurationModelFactory.AppConfigurationStoreData();

/// <summary>
/// Initializes a new instance of the <see cref="AppConfigurationStore"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ApplicationInsightsComponent : Resource<ApplicationInsightsComponen
// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/src/Generated/RestOperations/ComponentsRestOperations.cs#L36
internal const string DefaultVersion = "2020-02-02";

private static readonly Func<string, ApplicationInsightsComponentData> Empty = (name) => ArmApplicationInsightsModelFactory.ApplicationInsightsComponentData();
private static ApplicationInsightsComponentData Empty(string name) => ArmApplicationInsightsModelFactory.ApplicationInsightsComponentData();

/// <summary>
/// Creates a new instance of the <see cref="ApplicationInsightsComponentData"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class CognitiveServicesAccount : Resource<CognitiveServicesAccountData>
// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/AccountsRestOperations.cs#L36
private const string DefaultVersion = "2023-05-01";

private static readonly Func<string, CognitiveServicesAccountData> Empty = (name) => ArmCognitiveServicesModelFactory.CognitiveServicesAccountData();
private static CognitiveServicesAccountData Empty(string name) => ArmCognitiveServicesModelFactory.CognitiveServicesAccountData();

/// <summary>
/// Creates a new instance of the <see cref="CognitiveServicesAccount"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Azure.Provisioning.CognitiveServices
public class CognitiveServicesAccountDeployment : Resource<CognitiveServicesAccountDeploymentData>
{
private const string ResourceTypeName = "Microsoft.CognitiveServices/accounts/deployments";
private static readonly Func<string, CognitiveServicesAccountDeploymentData> Empty = (name) => ArmCognitiveServicesModelFactory.CognitiveServicesAccountDeploymentData();
private static CognitiveServicesAccountDeploymentData Empty (string name) => ArmCognitiveServicesModelFactory.CognitiveServicesAccountDeploymentData();

/// <summary>
/// Creates a new instance of the <see cref="CognitiveServicesAccount"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CosmosDBAccount : Resource<CosmosDBAccountData>
// TODO the version used in ARM library doesn't exist in docs, so we are using the latest documented version
internal const string DefaultVersion = "2023-04-15";

private static readonly Func<string, CosmosDBAccountData> Empty = (name) => ArmCosmosDBModelFactory.CosmosDBAccountData();
private static CosmosDBAccountData Empty(string name) => ArmCosmosDBModelFactory.CosmosDBAccountData();

/// <summary>
/// Creates a new instance of the <see cref="CosmosDBAccount"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Azure.Provisioning.CosmosDB
public class CosmosDBSqlDatabase : Resource<CosmosDBSqlDatabaseData>
{
private const string ResourceTypeName = "Microsoft.DocumentDB/databaseAccounts/sqlDatabases";
private static readonly Func<string, CosmosDBSqlDatabaseData> Empty = (name) => ArmCosmosDBModelFactory.CosmosDBSqlDatabaseData();
private static CosmosDBSqlDatabaseData Empty(string name) => ArmCosmosDBModelFactory.CosmosDBSqlDatabaseData();

/// <summary>
/// Initializes a new instance of the <see cref="CosmosDBSqlDatabase"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Azure.Provisioning.EventHubs
public class EventHubsConsumerGroup : Resource<EventHubsConsumerGroupData>
{
private const string ResourceTypeName = "Microsoft.EventHub/namespaces/eventhubs/consumergroups";
private static readonly Func<string, EventHubsConsumerGroupData> Empty = (name) => ArmEventHubsModelFactory.EventHubsConsumerGroupData();
private static EventHubsConsumerGroupData Empty(string name) => ArmEventHubsModelFactory.EventHubsConsumerGroupData();

/// <summary>
/// Initializes a new instance of the <see cref="EventHub"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class EventHubsNamespace : Resource<EventHubsNamespaceData>
// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventhub/Azure.ResourceManager.EventHubs/src/Generated/RestOperations/NamespacesRestOperations.cs#L36
internal const string DefaultVersion = "2022-10-01-preview";

private static readonly Func<string, EventHubsNamespaceData> Empty = (name) => ArmEventHubsModelFactory.EventHubsNamespaceData();
private static EventHubsNamespaceData Empty(string name) => ArmEventHubsModelFactory.EventHubsNamespaceData();

/// <summary>
/// Initializes a new instance of the <see cref="EventHubsNamespace"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class KeyVault : Resource<KeyVaultData>
// TODO the version used in ARM library doesn't exist in the docs so we are using the latest documented version
internal const string DefaultVersion = "2022-07-01";

private static readonly Func<string, KeyVaultData> Empty = (name) => ArmKeyVaultModelFactory.KeyVaultData();
private static KeyVaultData Empty(string name) => ArmKeyVaultModelFactory.KeyVaultData();

/// <summary>
/// Creates a new instance of the <see cref="KeyVault"/> class referencing an existing instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Azure.Provisioning.KeyVaults
public class KeyVaultSecret : Resource<KeyVaultSecretData>
{
private const string ResourceTypeName = "Microsoft.KeyVault/vaults/secrets";
private static readonly Func<string, KeyVaultSecretData> Empty = (name) => ArmKeyVaultModelFactory.KeyVaultSecretData();
private static KeyVaultSecretData Empty(string name) => ArmKeyVaultModelFactory.KeyVaultSecretData();

/// <summary>
/// Initializes a new instance of the <see cref="KeyVaultSecret"/>.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using Azure.Core;
using Azure.Provisioning.ResourceManager;
using Azure.ResourceManager.OperationalInsights;
using Azure.ResourceManager.OperationalInsights.Models;

namespace Azure.Provisioning.OperationalInsights
{
/// <summary>
/// Represents an Operational Insights workspace.
/// </summary>
public class OperationalInsightsWorkspace : Resource<OperationalInsightsWorkspaceData>
{
// https://learn.microsoft.com/azure/templates/microsoft.insights/2020-02-02/components?pivots=deployment-language-bicep
private const string ResourceTypeName = "Microsoft.Insights/components";
// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/RestOperations/WorkspacesRestOperations.cs#L36C42-L36C52
internal const string DefaultVersion = "2022-10-01";

private static OperationalInsightsWorkspaceData Empty(string name) => ArmOperationalInsightsModelFactory.OperationalInsightsWorkspaceData();

/// <summary>
/// Creates a new instance of the <see cref="OperationalInsightsWorkspaceData"/> class.
/// </summary>
/// <param name="scope">The scope.</param>
/// <param name="sku">The SKU.</param>
/// <param name="parent">The parent.</param>
/// <param name="name">The name.</param>
/// <param name="version">The version.</param>
/// <param name="location">The location</param>
public OperationalInsightsWorkspace(
IConstruct scope,
OperationalInsightsWorkspaceSku? sku = default,
ResourceGroup? parent = default,
string name = "opinsights",
string version = DefaultVersion,
AzureLocation? location = default)
: this(scope, parent, name, version, false, (name) => ArmOperationalInsightsModelFactory.OperationalInsightsWorkspaceData(
name: name,
location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS,
sku: new OperationalInsightsWorkspaceSku(OperationalInsightsWorkspaceSkuName.PerGB2018)))
{
AssignProperty(data => data.Name, GetAzureName(scope, name));
}

private OperationalInsightsWorkspace(
IConstruct scope,
ResourceGroup? parent,
string name,
string version = DefaultVersion,
bool isExisting = false,
Func<string, OperationalInsightsWorkspaceData>? creator = null)
: base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting)
{
}

/// <summary>
/// Creates a new instance of the <see cref="OperationalInsightsWorkspace"/> class referencing an existing instance.
/// </summary>
/// <param name="scope">The scope.</param>
/// <param name="name">The resource name.</param>
/// <param name="parent">The resource group.</param>
/// <returns>The KeyVault instance.</returns>
public static OperationalInsightsWorkspace FromExisting(IConstruct scope, string name, ResourceGroup? parent = null)
=> new OperationalInsightsWorkspace(scope, parent: parent, name: name, isExisting: true);

/// <inheritdoc/>
protected override string GetAzureName(IConstruct scope, string resourceName) => GetGloballyUniqueName(resourceName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Azure.Provisioning.PostgreSql
public class PostgreSqlFirewallRule : Resource<PostgreSqlFirewallRuleData>
{
private const string ResourceTypeName = "Microsoft.DBforPostgreSQL/flexibleServers/firewallRules";
private static readonly Func<string, PostgreSqlFirewallRuleData> Empty = (name) => ArmPostgreSqlModelFactory.PostgreSqlFirewallRuleData();
private static PostgreSqlFirewallRuleData Empty(string name) => ArmPostgreSqlModelFactory.PostgreSqlFirewallRuleData();

/// <summary>
/// Initializes a new instance of the <see cref="PostgreSqlFirewallRule"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class PostgreSqlFlexibleServer : Resource<PostgreSqlFlexibleServerData>
// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Generated/RestOperations/ServersRestOperations.cs#L37
internal const string DefaultVersion = "2023-03-01-preview";

private static readonly Func<string, PostgreSqlFlexibleServerData> Empty = (name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerData();
private static PostgreSqlFlexibleServerData Empty(string name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerData();

/// <summary>
/// Creates a new instance of the <see cref="PostgreSqlFlexibleServer"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Azure.Provisioning.PostgreSql
public class PostgreSqlFlexibleServerDatabase : Resource<PostgreSqlFlexibleServerDatabaseData>
{
private const string ResourceTypeName = "Microsoft.DBforPostgreSQL/flexibleServers/databases";
private static readonly Func<string, PostgreSqlFlexibleServerDatabaseData> Empty = (name)
private static PostgreSqlFlexibleServerDatabaseData Empty(string name)
=> ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerDatabaseData();

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class RedisCache : Resource<RedisData>
// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/redis/Azure.ResourceManager.Redis/src/Generated/RestOperations/RedisRestOperations.cs#L36
private const string DefaultVersion = "2023-08-01";

private static readonly Func<string, RedisData> Empty = (name) => ArmRedisModelFactory.RedisData(updateChannel: null);
private static RedisData Empty(string name) => ArmRedisModelFactory.RedisData(updateChannel: null);

/// <summary>
/// Creates a new instance of the <see cref="RedisCache"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class DeploymentScript : Resource<AzureCliScript>
// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resources/Azure.ResourceManager.Resources/src/Generated/RestOperations/DeploymentScriptsRestOperations.cs#L36
private const string DefaultVersion = "2020-10-01";

private static readonly Func<string, AzureCliScript> Empty = (name) => ArmResourcesModelFactory.AzureCliScript();
private static AzureCliScript Empty(string name) => ArmResourcesModelFactory.AzureCliScript();

/// <summary>
/// Initializes a new instance of the <see cref="DeploymentScript"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class SearchService : Resource<SearchServiceData>
// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.ResourceManager.Search/src/Generated/RestOperations/ServicesRestOperations.cs#L36
private const string DefaultVersion = "2023-11-01";

private static readonly Func<string, SearchServiceData> Empty = (name) => ArmSearchModelFactory.SearchServiceData();
private static SearchServiceData Empty(string name) => ArmSearchModelFactory.SearchServiceData();

/// <summary>
/// Creates a new instance of the <see cref="SearchService"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ServiceBusNamespace : Resource<ServiceBusNamespaceData>
// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/servicebus/Azure.ResourceManager.ServiceBus/src/Generated/RestOperations/NamespacesRestOperations.cs#L36C42-L36C60
internal const string DefaultVersion = "2022-10-01-preview";

private static readonly Func<string, ServiceBusNamespaceData> Empty = (name) => ArmServiceBusModelFactory.ServiceBusNamespaceData();
private static ServiceBusNamespaceData Empty(string name) => ArmServiceBusModelFactory.ServiceBusNamespaceData();

/// <summary>
/// Initializes a new instance of the <see cref="ServiceBusNamespace"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Azure.Provisioning.ServiceBus
public class ServiceBusQueue : Resource<ServiceBusQueueData>
{
private const string ResourceTypeName = "Microsoft.ServiceBus/namespaces/queues";
private static readonly Func<string, ServiceBusQueueData> Empty = (name) => ArmServiceBusModelFactory.ServiceBusQueueData();
private static ServiceBusQueueData Empty(string name) => ArmServiceBusModelFactory.ServiceBusQueueData();

/// <summary>
/// Initializes a new instance of the <see cref="ServiceBusQueue"/>.
Expand Down
Loading

0 comments on commit 9463d82

Please sign in to comment.