Skip to content

Commit

Permalink
New Resource: azurerm_time_series_insights_environment (#7012)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbfrahry committed May 21, 2020
1 parent d1f533d commit 4267a85
Show file tree
Hide file tree
Showing 21 changed files with 6,359 additions and 73 deletions.
147 changes: 75 additions & 72 deletions azurerm/internal/clients/client.go
Expand Up @@ -37,6 +37,7 @@ import (
healthcare "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/healthcare/client"
iotcentral "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/iotcentral/client"
iothub "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/iothub/client"
timeseriesinsights "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/iottimeseriesinsights/client"
keyvault "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/keyvault/client"
kusto "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/kusto/client"
loganalytics "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/client"
Expand Down Expand Up @@ -86,77 +87,78 @@ type Client struct {
Account *ResourceManagerAccount
Features features.UserFeatures

AnalysisServices *analysisServices.Client
ApiManagement *apiManagement.Client
AppConfiguration *appConfiguration.Client
AppInsights *applicationInsights.Client
AppPlatform *appPlatform.Client
Authorization *authorization.Client
Automation *automation.Client
Batch *batch.Client
Bot *bot.Client
Cdn *cdn.Client
Cognitive *cognitiveServices.Client
Compute *compute.Client
Containers *containerServices.Client
Cosmos *cosmosdb.Client
CostManagement *costmanagement.Client
CustomProviders *customproviders.Client
DatabaseMigration *datamigration.Client
DataBricks *databricks.Client
DataFactory *datafactory.Client
Datalake *datalake.Client
DataShare *datashare.Client
DevSpace *devspace.Client
DevTestLabs *devtestlabs.Client
Dns *dns.Client
EventGrid *eventgrid.Client
Eventhub *eventhub.Client
Frontdoor *frontdoor.Client
HDInsight *hdinsight.Client
HealthCare *healthcare.Client
IoTHub *iothub.Client
IoTCentral *iotcentral.Client
KeyVault *keyvault.Client
Kusto *kusto.Client
LogAnalytics *loganalytics.Client
Logic *logic.Client
MachineLearning *machinelearning.Client
Maintenance *maintenance.Client
ManagedApplication *managedapplication.Client
ManagementGroups *managementgroup.Client
Maps *maps.Client
MariaDB *mariadb.Client
Media *media.Client
MixedReality *mixedreality.Client
Monitor *monitor.Client
MSI *msi.Client
MSSQL *mssql.Client
MySQL *mysql.Client
NetApp *netapp.Client
Network *network.Client
NotificationHubs *notificationhub.Client
Policy *policy.Client
Portal *portal.Client
Postgres *postgres.Client
PowerBI *powerBI.Client
PrivateDns *privatedns.Client
RecoveryServices *recoveryServices.Client
Redis *redis.Client
Relay *relay.Client
Resource *resource.Client
Search *search.Client
SecurityCenter *securityCenter.Client
Sentinel *sentinel.Client
ServiceBus *serviceBus.Client
ServiceFabric *serviceFabric.Client
SignalR *signalr.Client
Storage *storage.Client
StreamAnalytics *streamAnalytics.Client
Subscription *subscription.Client
Sql *sql.Client
TrafficManager *trafficManager.Client
Web *web.Client
AnalysisServices *analysisServices.Client
ApiManagement *apiManagement.Client
AppConfiguration *appConfiguration.Client
AppInsights *applicationInsights.Client
AppPlatform *appPlatform.Client
Authorization *authorization.Client
Automation *automation.Client
Batch *batch.Client
Bot *bot.Client
Cdn *cdn.Client
Cognitive *cognitiveServices.Client
Compute *compute.Client
Containers *containerServices.Client
Cosmos *cosmosdb.Client
CostManagement *costmanagement.Client
CustomProviders *customproviders.Client
DatabaseMigration *datamigration.Client
DataBricks *databricks.Client
DataFactory *datafactory.Client
Datalake *datalake.Client
DataShare *datashare.Client
DevSpace *devspace.Client
DevTestLabs *devtestlabs.Client
Dns *dns.Client
EventGrid *eventgrid.Client
Eventhub *eventhub.Client
Frontdoor *frontdoor.Client
HDInsight *hdinsight.Client
HealthCare *healthcare.Client
IoTCentral *iotcentral.Client
IoTHub *iothub.Client
IoTTimeSeriesInsights *timeseriesinsights.Client
KeyVault *keyvault.Client
Kusto *kusto.Client
LogAnalytics *loganalytics.Client
Logic *logic.Client
MachineLearning *machinelearning.Client
Maintenance *maintenance.Client
ManagedApplication *managedapplication.Client
ManagementGroups *managementgroup.Client
Maps *maps.Client
MariaDB *mariadb.Client
Media *media.Client
MixedReality *mixedreality.Client
Monitor *monitor.Client
MSI *msi.Client
MSSQL *mssql.Client
MySQL *mysql.Client
NetApp *netapp.Client
Network *network.Client
NotificationHubs *notificationhub.Client
Policy *policy.Client
Portal *portal.Client
Postgres *postgres.Client
PowerBI *powerBI.Client
PrivateDns *privatedns.Client
RecoveryServices *recoveryServices.Client
Redis *redis.Client
Relay *relay.Client
Resource *resource.Client
Search *search.Client
SecurityCenter *securityCenter.Client
Sentinel *sentinel.Client
ServiceBus *serviceBus.Client
ServiceFabric *serviceFabric.Client
SignalR *signalr.Client
Storage *storage.Client
StreamAnalytics *streamAnalytics.Client
Subscription *subscription.Client
Sql *sql.Client
TrafficManager *trafficManager.Client
Web *web.Client
}

// NOTE: it should be possible for this method to become Private once the top level Client's removed
Expand Down Expand Up @@ -196,8 +198,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
client.Frontdoor = frontdoor.NewClient(o)
client.HDInsight = hdinsight.NewClient(o)
client.HealthCare = healthcare.NewClient(o)
client.IoTHub = iothub.NewClient(o)
client.IoTCentral = iotcentral.NewClient(o)
client.IoTHub = iothub.NewClient(o)
client.IoTTimeSeriesInsights = timeseriesinsights.NewClient(o)
client.KeyVault = keyvault.NewClient(o)
client.Kusto = kusto.NewClient(o)
client.LogAnalytics = loganalytics.NewClient(o)
Expand Down
1 change: 1 addition & 0 deletions azurerm/internal/provider/required_resource_providers.go
Expand Up @@ -74,6 +74,7 @@ func RequiredResourceProviders() map[string]struct{} {
"Microsoft.Storage": {},
"Microsoft.StorageCache": {},
"Microsoft.StreamAnalytics": {},
"Microsoft.TimeSeriesInsights": {},
"Microsoft.Web": {},
}
}
Expand Down
2 changes: 2 additions & 0 deletions azurerm/internal/provider/services.go
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/healthcare"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/iotcentral"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/iothub"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/iottimeseriesinsights"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/keyvault"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/kusto"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics"
Expand Down Expand Up @@ -148,6 +149,7 @@ func SupportedServices() []common.ServiceRegistration {
storage.Registration{},
streamanalytics.Registration{},
subscription.Registration{},
iottimeseriesinsights.Registration{},
trafficmanager.Registration{},
web.Registration{},
}
Expand Down
19 changes: 19 additions & 0 deletions azurerm/internal/services/iottimeseriesinsights/client/client.go
@@ -0,0 +1,19 @@
package client

import (
"github.com/Azure/azure-sdk-for-go/services/preview/timeseriesinsights/mgmt/2018-08-15-preview/timeseriesinsights"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common"
)

type Client struct {
EnvironmentsClient *timeseriesinsights.EnvironmentsClient
}

func NewClient(o *common.ClientOptions) *Client {
EnvironmentsClient := timeseriesinsights.NewEnvironmentsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&EnvironmentsClient.Client, o.ResourceManagerAuthorizer)

return &Client{
EnvironmentsClient: &EnvironmentsClient,
}
}
@@ -0,0 +1,33 @@
package parse

import (
"fmt"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
)

type TimeSeriesInsightsEnvironmentId struct {
ResourceGroup string
Name string
}

func TimeSeriesInsightsEnvironmentID(input string) (*TimeSeriesInsightsEnvironmentId, error) {
id, err := azure.ParseAzureResourceID(input)
if err != nil {
return nil, fmt.Errorf("parsing Time Series Insights Environment ID %q: %+v", input, err)
}

service := TimeSeriesInsightsEnvironmentId{
ResourceGroup: id.ResourceGroup,
}

if service.Name, err = id.PopSegment("environments"); err != nil {
return nil, err
}

if err := id.ValidateNoEmptySegments(input); err != nil {
return nil, err
}

return &service, nil
}
@@ -0,0 +1,73 @@
package parse

import (
"testing"
)

func TestTimeSeriesInsightsEnvironmentId(t *testing.T) {
testData := []struct {
Name string
Input string
Expected *TimeSeriesInsightsEnvironmentId
}{
{
Name: "Empty",
Input: "",
Expected: nil,
},
{
Name: "No Resource Groups Segment",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000",
Expected: nil,
},
{
Name: "No Resource Groups Value",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/",
Expected: nil,
},
{
Name: "Resource Group ID",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/",
Expected: nil,
},
{
Name: "Time Series Insight Environment Value",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.TimeSeriesInsights/environments/",
Expected: nil,
},
{
Name: "Time Series Insight Environment ID",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.TimeSeriesInsights/environments/Environment1",
Expected: &TimeSeriesInsightsEnvironmentId{
Name: "Environment1",
ResourceGroup: "resGroup1",
},
},
{
Name: "Wrong Casing",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.TimeSeriesInsights/Environments/Environment1",
Expected: nil,
},
}

for _, v := range testData {
t.Logf("[DEBUG] Testing %q", v.Name)

actual, err := TimeSeriesInsightsEnvironmentID(v.Input)
if err != nil {
if v.Expected == nil {
continue
}

t.Fatalf("Expected a value but got an error: %s", err)
}

if actual.Name != v.Expected.Name {
t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name)
}

if actual.ResourceGroup != v.Expected.ResourceGroup {
t.Fatalf("Expected %q but got %q for Resource Group", v.Expected.ResourceGroup, actual.ResourceGroup)
}
}
}
31 changes: 31 additions & 0 deletions azurerm/internal/services/iottimeseriesinsights/registration.go
@@ -0,0 +1,31 @@
package iottimeseriesinsights

import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

type Registration struct{}

// Name is the name of this Service
func (r Registration) Name() string {
return "Time Series Insights"
}

// WebsiteCategories returns a list of categories which can be used for the sidebar
func (r Registration) WebsiteCategories() []string {
return []string{
"Time Series Insights",
}
}

// SupportedDataSources returns the supported Data Sources supported by this Service
func (r Registration) SupportedDataSources() map[string]*schema.Resource {
return map[string]*schema.Resource{}
}

// SupportedResources returns the supported Resources supported by this Service
func (r Registration) SupportedResources() map[string]*schema.Resource {
return map[string]*schema.Resource{
"azurerm_iot_time_series_insights_standard_environment": resourceArmIoTTimeSeriesInsightsStandardEnvironment(),
}
}

0 comments on commit 4267a85

Please sign in to comment.