forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stream_analytics_output.go
65 lines (58 loc) · 2.85 KB
/
stream_analytics_output.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package streamanalytics
import (
"context"
"fmt"
"github.com/Azure/azure-sdk-for-go/services/preview/streamanalytics/mgmt/2020-03-01-preview/streamanalytics"
"github.com/kevinklinger/terraform-provider-azurerm/v2/internal/clients"
"github.com/kevinklinger/terraform-provider-azurerm/v2/internal/services/streamanalytics/parse"
"github.com/kevinklinger/terraform-provider-azurerm/v2/internal/tf/pluginsdk"
)
func importStreamAnalyticsOutput(expectType streamanalytics.TypeBasicOutputDataSource) pluginsdk.ImporterFunc {
return func(ctx context.Context, d *pluginsdk.ResourceData, meta interface{}) (data []*pluginsdk.ResourceData, err error) {
id, err := parse.OutputID(d.Id())
if err != nil {
return nil, err
}
client := meta.(*clients.Client).StreamAnalytics.OutputsClient
resp, err := client.Get(ctx, id.ResourceGroup, id.StreamingjobName, id.Name)
if err != nil {
return nil, fmt.Errorf("retrieving %s: %+v", *id, err)
}
if props := resp.OutputProperties; props != nil {
var actualType streamanalytics.TypeBasicOutputDataSource
if datasource, ok := props.Datasource.AsBlobOutputDataSource(); ok {
actualType = datasource.Type
} else if datasource, ok := props.Datasource.AsAzureTableOutputDataSource(); ok {
actualType = datasource.Type
} else if datasource, ok := props.Datasource.AsEventHubOutputDataSource(); ok {
actualType = datasource.Type
} else if datasource, ok := props.Datasource.AsEventHubV2OutputDataSource(); ok {
actualType = datasource.Type
} else if datasource, ok := props.Datasource.AsAzureSQLDatabaseOutputDataSource(); ok {
actualType = datasource.Type
} else if datasource, ok := props.Datasource.AsAzureSynapseOutputDataSource(); ok {
actualType = datasource.Type
} else if datasource, ok := props.Datasource.AsDocumentDbOutputDataSource(); ok {
actualType = datasource.Type
} else if datasource, ok := props.Datasource.AsAzureFunctionOutputDataSource(); ok {
actualType = datasource.Type
} else if datasource, ok := props.Datasource.AsServiceBusQueueOutputDataSource(); ok {
actualType = datasource.Type
} else if datasource, ok := props.Datasource.AsServiceBusTopicOutputDataSource(); ok {
actualType = datasource.Type
} else if datasource, ok := props.Datasource.AsPowerBIOutputDataSource(); ok {
actualType = datasource.Type
} else if datasource, ok := props.Datasource.AsAzureDataLakeStoreOutputDataSource(); ok {
actualType = datasource.Type
} else if datasource, ok := props.Datasource.AsOutputDataSource(); ok {
actualType = datasource.Type
} else {
return nil, fmt.Errorf("unable to convert output data source: %+v", props.Datasource)
}
if actualType != expectType {
return nil, fmt.Errorf("stream analytics output has mismatched type, expected: %q, got %q", expectType, actualType)
}
}
return []*pluginsdk.ResourceData{d}, nil
}
}