15
15
package vertexai
16
16
17
17
import (
18
+ "encoding/json"
18
19
"reflect"
19
20
20
21
"github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/cai"
@@ -66,6 +67,12 @@ func GetVertexAIEndpointApiObject(d tpgresource.TerraformResourceData, config *t
66
67
} else if v , ok := d .GetOkExists ("description" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (descriptionProp )) && (ok || ! reflect .DeepEqual (v , descriptionProp )) {
67
68
obj ["description" ] = descriptionProp
68
69
}
70
+ trafficSplitProp , err := expandVertexAIEndpointTrafficSplit (d .Get ("traffic_split" ), d , config )
71
+ if err != nil {
72
+ return nil , err
73
+ } else if v , ok := d .GetOkExists ("traffic_split" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (trafficSplitProp )) && (ok || ! reflect .DeepEqual (v , trafficSplitProp )) {
74
+ obj ["trafficSplit" ] = trafficSplitProp
75
+ }
69
76
encryptionSpecProp , err := expandVertexAIEndpointEncryptionSpec (d .Get ("encryption_spec" ), d , config )
70
77
if err != nil {
71
78
return nil , err
@@ -78,6 +85,24 @@ func GetVertexAIEndpointApiObject(d tpgresource.TerraformResourceData, config *t
78
85
} else if v , ok := d .GetOkExists ("network" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (networkProp )) && (ok || ! reflect .DeepEqual (v , networkProp )) {
79
86
obj ["network" ] = networkProp
80
87
}
88
+ privateServiceConnectConfigProp , err := expandVertexAIEndpointPrivateServiceConnectConfig (d .Get ("private_service_connect_config" ), d , config )
89
+ if err != nil {
90
+ return nil , err
91
+ } else if v , ok := d .GetOkExists ("private_service_connect_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (privateServiceConnectConfigProp )) && (ok || ! reflect .DeepEqual (v , privateServiceConnectConfigProp )) {
92
+ obj ["privateServiceConnectConfig" ] = privateServiceConnectConfigProp
93
+ }
94
+ predictRequestResponseLoggingConfigProp , err := expandVertexAIEndpointPredictRequestResponseLoggingConfig (d .Get ("predict_request_response_logging_config" ), d , config )
95
+ if err != nil {
96
+ return nil , err
97
+ } else if v , ok := d .GetOkExists ("predict_request_response_logging_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (predictRequestResponseLoggingConfigProp )) && (ok || ! reflect .DeepEqual (v , predictRequestResponseLoggingConfigProp )) {
98
+ obj ["predictRequestResponseLoggingConfig" ] = predictRequestResponseLoggingConfigProp
99
+ }
100
+ dedicatedEndpointEnabledProp , err := expandVertexAIEndpointDedicatedEndpointEnabled (d .Get ("dedicated_endpoint_enabled" ), d , config )
101
+ if err != nil {
102
+ return nil , err
103
+ } else if v , ok := d .GetOkExists ("dedicated_endpoint_enabled" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (dedicatedEndpointEnabledProp )) && (ok || ! reflect .DeepEqual (v , dedicatedEndpointEnabledProp )) {
104
+ obj ["dedicatedEndpointEnabled" ] = dedicatedEndpointEnabledProp
105
+ }
81
106
labelsProp , err := expandVertexAIEndpointEffectiveLabels (d .Get ("effective_labels" ), d , config )
82
107
if err != nil {
83
108
return nil , err
@@ -96,6 +121,18 @@ func expandVertexAIEndpointDescription(v interface{}, d tpgresource.TerraformRes
96
121
return v , nil
97
122
}
98
123
124
+ func expandVertexAIEndpointTrafficSplit (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
125
+ b := []byte (v .(string ))
126
+ if len (b ) == 0 {
127
+ return nil , nil
128
+ }
129
+ m := make (map [string ]interface {})
130
+ if err := json .Unmarshal (b , & m ); err != nil {
131
+ return nil , err
132
+ }
133
+ return m , nil
134
+ }
135
+
99
136
func expandVertexAIEndpointEncryptionSpec (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
100
137
l := v .([]interface {})
101
138
if len (l ) == 0 || l [0 ] == nil {
@@ -123,6 +160,119 @@ func expandVertexAIEndpointNetwork(v interface{}, d tpgresource.TerraformResourc
123
160
return v , nil
124
161
}
125
162
163
+ func expandVertexAIEndpointPrivateServiceConnectConfig (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
164
+ l := v .([]interface {})
165
+ if len (l ) == 0 || l [0 ] == nil {
166
+ return nil , nil
167
+ }
168
+ raw := l [0 ]
169
+ original := raw .(map [string ]interface {})
170
+ transformed := make (map [string ]interface {})
171
+
172
+ transformedEnablePrivateServiceConnect , err := expandVertexAIEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect (original ["enable_private_service_connect" ], d , config )
173
+ if err != nil {
174
+ return nil , err
175
+ } else if val := reflect .ValueOf (transformedEnablePrivateServiceConnect ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
176
+ transformed ["enablePrivateServiceConnect" ] = transformedEnablePrivateServiceConnect
177
+ }
178
+
179
+ transformedProjectAllowlist , err := expandVertexAIEndpointPrivateServiceConnectConfigProjectAllowlist (original ["project_allowlist" ], d , config )
180
+ if err != nil {
181
+ return nil , err
182
+ } else if val := reflect .ValueOf (transformedProjectAllowlist ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
183
+ transformed ["projectAllowlist" ] = transformedProjectAllowlist
184
+ }
185
+
186
+ transformedEnableSecurePrivateServiceConnect , err := expandVertexAIEndpointPrivateServiceConnectConfigEnableSecurePrivateServiceConnect (original ["enable_secure_private_service_connect" ], d , config )
187
+ if err != nil {
188
+ return nil , err
189
+ } else if val := reflect .ValueOf (transformedEnableSecurePrivateServiceConnect ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
190
+ transformed ["enableSecurePrivateServiceConnect" ] = transformedEnableSecurePrivateServiceConnect
191
+ }
192
+
193
+ return transformed , nil
194
+ }
195
+
196
+ func expandVertexAIEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
197
+ return v , nil
198
+ }
199
+
200
+ func expandVertexAIEndpointPrivateServiceConnectConfigProjectAllowlist (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
201
+ return v , nil
202
+ }
203
+
204
+ func expandVertexAIEndpointPrivateServiceConnectConfigEnableSecurePrivateServiceConnect (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
205
+ return v , nil
206
+ }
207
+
208
+ func expandVertexAIEndpointPredictRequestResponseLoggingConfig (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
209
+ l := v .([]interface {})
210
+ if len (l ) == 0 || l [0 ] == nil {
211
+ return nil , nil
212
+ }
213
+ raw := l [0 ]
214
+ original := raw .(map [string ]interface {})
215
+ transformed := make (map [string ]interface {})
216
+
217
+ transformedEnabled , err := expandVertexAIEndpointPredictRequestResponseLoggingConfigEnabled (original ["enabled" ], d , config )
218
+ if err != nil {
219
+ return nil , err
220
+ } else if val := reflect .ValueOf (transformedEnabled ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
221
+ transformed ["enabled" ] = transformedEnabled
222
+ }
223
+
224
+ transformedSamplingRate , err := expandVertexAIEndpointPredictRequestResponseLoggingConfigSamplingRate (original ["sampling_rate" ], d , config )
225
+ if err != nil {
226
+ return nil , err
227
+ } else if val := reflect .ValueOf (transformedSamplingRate ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
228
+ transformed ["samplingRate" ] = transformedSamplingRate
229
+ }
230
+
231
+ transformedBigqueryDestination , err := expandVertexAIEndpointPredictRequestResponseLoggingConfigBigqueryDestination (original ["bigquery_destination" ], d , config )
232
+ if err != nil {
233
+ return nil , err
234
+ } else if val := reflect .ValueOf (transformedBigqueryDestination ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
235
+ transformed ["bigqueryDestination" ] = transformedBigqueryDestination
236
+ }
237
+
238
+ return transformed , nil
239
+ }
240
+
241
+ func expandVertexAIEndpointPredictRequestResponseLoggingConfigEnabled (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
242
+ return v , nil
243
+ }
244
+
245
+ func expandVertexAIEndpointPredictRequestResponseLoggingConfigSamplingRate (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
246
+ return v , nil
247
+ }
248
+
249
+ func expandVertexAIEndpointPredictRequestResponseLoggingConfigBigqueryDestination (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
250
+ l := v .([]interface {})
251
+ if len (l ) == 0 || l [0 ] == nil {
252
+ return nil , nil
253
+ }
254
+ raw := l [0 ]
255
+ original := raw .(map [string ]interface {})
256
+ transformed := make (map [string ]interface {})
257
+
258
+ transformedOutputUri , err := expandVertexAIEndpointPredictRequestResponseLoggingConfigBigqueryDestinationOutputUri (original ["output_uri" ], d , config )
259
+ if err != nil {
260
+ return nil , err
261
+ } else if val := reflect .ValueOf (transformedOutputUri ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
262
+ transformed ["outputUri" ] = transformedOutputUri
263
+ }
264
+
265
+ return transformed , nil
266
+ }
267
+
268
+ func expandVertexAIEndpointPredictRequestResponseLoggingConfigBigqueryDestinationOutputUri (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
269
+ return v , nil
270
+ }
271
+
272
+ func expandVertexAIEndpointDedicatedEndpointEnabled (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
273
+ return v , nil
274
+ }
275
+
126
276
func expandVertexAIEndpointEffectiveLabels (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (map [string ]string , error ) {
127
277
if v == nil {
128
278
return map [string ]string {}, nil
0 commit comments