/
beyondcorp_app_connection.go
202 lines (175 loc) · 7.43 KB
/
beyondcorp_app_connection.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
// ----------------------------------------------------------------------------
//
// *** 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 BeyondcorpAppConnectionAssetType string = "beyondcorp.googleapis.com/AppConnection"
func resourceConverterBeyondcorpAppConnection() ResourceConverter {
return ResourceConverter{
AssetType: BeyondcorpAppConnectionAssetType,
Convert: GetBeyondcorpAppConnectionCaiObject,
}
}
func GetBeyondcorpAppConnectionCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) {
name, err := assetName(d, config, "//beyondcorp.googleapis.com/projects/{{project}}/locations/{{region}}/appConnections/{{name}}")
if err != nil {
return []Asset{}, err
}
if obj, err := GetBeyondcorpAppConnectionApiObject(d, config); err == nil {
return []Asset{{
Name: name,
Type: BeyondcorpAppConnectionAssetType,
Resource: &AssetResource{
Version: "v1",
DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/beyondcorp/v1/rest",
DiscoveryName: "AppConnection",
Data: obj,
},
}}, nil
} else {
return []Asset{}, err
}
}
func GetBeyondcorpAppConnectionApiObject(d TerraformResourceData, config *Config) (map[string]interface{}, error) {
obj := make(map[string]interface{})
displayNameProp, err := expandBeyondcorpAppConnectionDisplayName(d.Get("display_name"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("display_name"); !isEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) {
obj["displayName"] = displayNameProp
}
labelsProp, err := expandBeyondcorpAppConnectionLabels(d.Get("labels"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("labels"); !isEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) {
obj["labels"] = labelsProp
}
typeProp, err := expandBeyondcorpAppConnectionType(d.Get("type"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("type"); !isEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) {
obj["type"] = typeProp
}
applicationEndpointProp, err := expandBeyondcorpAppConnectionApplicationEndpoint(d.Get("application_endpoint"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("application_endpoint"); !isEmptyValue(reflect.ValueOf(applicationEndpointProp)) && (ok || !reflect.DeepEqual(v, applicationEndpointProp)) {
obj["applicationEndpoint"] = applicationEndpointProp
}
connectorsProp, err := expandBeyondcorpAppConnectionConnectors(d.Get("connectors"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("connectors"); !isEmptyValue(reflect.ValueOf(connectorsProp)) && (ok || !reflect.DeepEqual(v, connectorsProp)) {
obj["connectors"] = connectorsProp
}
gatewayProp, err := expandBeyondcorpAppConnectionGateway(d.Get("gateway"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("gateway"); !isEmptyValue(reflect.ValueOf(gatewayProp)) && (ok || !reflect.DeepEqual(v, gatewayProp)) {
obj["gateway"] = gatewayProp
}
return obj, nil
}
func expandBeyondcorpAppConnectionDisplayName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandBeyondcorpAppConnectionLabels(v interface{}, d TerraformResourceData, config *Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
}
m := make(map[string]string)
for k, val := range v.(map[string]interface{}) {
m[k] = val.(string)
}
return m, nil
}
func expandBeyondcorpAppConnectionType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandBeyondcorpAppConnectionApplicationEndpoint(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{})
transformedHost, err := expandBeyondcorpAppConnectionApplicationEndpointHost(original["host"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedHost); val.IsValid() && !isEmptyValue(val) {
transformed["host"] = transformedHost
}
transformedPort, err := expandBeyondcorpAppConnectionApplicationEndpointPort(original["port"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedPort); val.IsValid() && !isEmptyValue(val) {
transformed["port"] = transformedPort
}
return transformed, nil
}
func expandBeyondcorpAppConnectionApplicationEndpointHost(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandBeyondcorpAppConnectionApplicationEndpointPort(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandBeyondcorpAppConnectionConnectors(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandBeyondcorpAppConnectionGateway(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{})
transformedAppGateway, err := expandBeyondcorpAppConnectionGatewayAppGateway(original["app_gateway"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedAppGateway); val.IsValid() && !isEmptyValue(val) {
transformed["appGateway"] = transformedAppGateway
}
transformedType, err := expandBeyondcorpAppConnectionGatewayType(original["type"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedType); val.IsValid() && !isEmptyValue(val) {
transformed["type"] = transformedType
}
transformedUri, err := expandBeyondcorpAppConnectionGatewayUri(original["uri"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedUri); val.IsValid() && !isEmptyValue(val) {
transformed["uri"] = transformedUri
}
transformedIngressPort, err := expandBeyondcorpAppConnectionGatewayIngressPort(original["ingress_port"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedIngressPort); val.IsValid() && !isEmptyValue(val) {
transformed["ingressPort"] = transformedIngressPort
}
return transformed, nil
}
func expandBeyondcorpAppConnectionGatewayAppGateway(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandBeyondcorpAppConnectionGatewayType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandBeyondcorpAppConnectionGatewayUri(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandBeyondcorpAppConnectionGatewayIngressPort(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}