/
securitycenter_notification_config.go
102 lines (89 loc) · 3.84 KB
/
securitycenter_notification_config.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------
package google
import "reflect"
const SecurityCenterNotificationConfigAssetType string = "securitycenter.googleapis.com/NotificationConfig"
func resourceConverterSecurityCenterNotificationConfig() ResourceConverter {
return ResourceConverter{
AssetType: SecurityCenterNotificationConfigAssetType,
Convert: GetSecurityCenterNotificationConfigCaiObject,
}
}
func GetSecurityCenterNotificationConfigCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) {
name, err := assetName(d, config, "//securitycenter.googleapis.com/{{name}}")
if err != nil {
return []Asset{}, err
}
if obj, err := GetSecurityCenterNotificationConfigApiObject(d, config); err == nil {
return []Asset{{
Name: name,
Type: SecurityCenterNotificationConfigAssetType,
Resource: &AssetResource{
Version: "v1",
DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/securitycenter/v1/rest",
DiscoveryName: "NotificationConfig",
Data: obj,
},
}}, nil
} else {
return []Asset{}, err
}
}
func GetSecurityCenterNotificationConfigApiObject(d TerraformResourceData, config *Config) (map[string]interface{}, error) {
obj := make(map[string]interface{})
descriptionProp, err := expandSecurityCenterNotificationConfigDescription(d.Get("description"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
obj["description"] = descriptionProp
}
pubsubTopicProp, err := expandSecurityCenterNotificationConfigPubsubTopic(d.Get("pubsub_topic"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("pubsub_topic"); !isEmptyValue(reflect.ValueOf(pubsubTopicProp)) && (ok || !reflect.DeepEqual(v, pubsubTopicProp)) {
obj["pubsubTopic"] = pubsubTopicProp
}
streamingConfigProp, err := expandSecurityCenterNotificationConfigStreamingConfig(d.Get("streaming_config"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("streaming_config"); !isEmptyValue(reflect.ValueOf(streamingConfigProp)) && (ok || !reflect.DeepEqual(v, streamingConfigProp)) {
obj["streamingConfig"] = streamingConfigProp
}
return obj, nil
}
func expandSecurityCenterNotificationConfigDescription(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandSecurityCenterNotificationConfigPubsubTopic(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandSecurityCenterNotificationConfigStreamingConfig(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})
transformedFilter, err := expandSecurityCenterNotificationConfigStreamingConfigFilter(original["filter"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedFilter); val.IsValid() && !isEmptyValue(val) {
transformed["filter"] = transformedFilter
}
return transformed, nil
}
func expandSecurityCenterNotificationConfigStreamingConfigFilter(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}