1717package discoveryengine
1818
1919import (
20+ "encoding/json"
2021 "reflect"
2122
23+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
24+
2225 "github.com/GoogleCloudPlatform/terraform-google-conversion/v7/tfplan2cai/converters/google/resources/cai"
2326 "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
2427 transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
2528)
2629
30+ func DataConnectorEntitiesParamsDiffSuppress (k , old , new string , d * schema.ResourceData ) bool {
31+ return (old == "" && new == "{}" ) || (old == "{}" && new == "" )
32+ }
33+
2734const DiscoveryEngineDataConnectorAssetType string = "{{location}}-discoveryengine.googleapis.com/DataConnector"
2835
2936func ResourceConverterDiscoveryEngineDataConnector () cai.ResourceConverter {
@@ -98,6 +105,36 @@ func GetDiscoveryEngineDataConnectorApiObject(d tpgresource.TerraformResourceDat
98105 } else if v , ok := d .GetOkExists ("static_ip_enabled" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (staticIpEnabledProp )) && (ok || ! reflect .DeepEqual (v , staticIpEnabledProp )) {
99106 obj ["staticIpEnabled" ] = staticIpEnabledProp
100107 }
108+ connectorModesProp , err := expandDiscoveryEngineDataConnectorConnectorModes (d .Get ("connector_modes" ), d , config )
109+ if err != nil {
110+ return nil , err
111+ } else if v , ok := d .GetOkExists ("connector_modes" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (connectorModesProp )) && (ok || ! reflect .DeepEqual (v , connectorModesProp )) {
112+ obj ["connectorModes" ] = connectorModesProp
113+ }
114+ syncModeProp , err := expandDiscoveryEngineDataConnectorSyncMode (d .Get ("sync_mode" ), d , config )
115+ if err != nil {
116+ return nil , err
117+ } else if v , ok := d .GetOkExists ("sync_mode" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (syncModeProp )) && (ok || ! reflect .DeepEqual (v , syncModeProp )) {
118+ obj ["syncMode" ] = syncModeProp
119+ }
120+ incrementalRefreshIntervalProp , err := expandDiscoveryEngineDataConnectorIncrementalRefreshInterval (d .Get ("incremental_refresh_interval" ), d , config )
121+ if err != nil {
122+ return nil , err
123+ } else if v , ok := d .GetOkExists ("incremental_refresh_interval" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (incrementalRefreshIntervalProp )) && (ok || ! reflect .DeepEqual (v , incrementalRefreshIntervalProp )) {
124+ obj ["incrementalRefreshInterval" ] = incrementalRefreshIntervalProp
125+ }
126+ autoRunDisabledProp , err := expandDiscoveryEngineDataConnectorAutoRunDisabled (d .Get ("auto_run_disabled" ), d , config )
127+ if err != nil {
128+ return nil , err
129+ } else if v , ok := d .GetOkExists ("auto_run_disabled" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (autoRunDisabledProp )) && (ok || ! reflect .DeepEqual (v , autoRunDisabledProp )) {
130+ obj ["autoRunDisabled" ] = autoRunDisabledProp
131+ }
132+ incrementalSyncDisabledProp , err := expandDiscoveryEngineDataConnectorIncrementalSyncDisabled (d .Get ("incremental_sync_disabled" ), d , config )
133+ if err != nil {
134+ return nil , err
135+ } else if v , ok := d .GetOkExists ("incremental_sync_disabled" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (incrementalSyncDisabledProp )) && (ok || ! reflect .DeepEqual (v , incrementalSyncDisabledProp )) {
136+ obj ["incrementalSyncDisabled" ] = incrementalSyncDisabledProp
137+ }
101138
102139 return obj , nil
103140}
@@ -190,13 +227,14 @@ func expandDiscoveryEngineDataConnectorEntitiesDataStore(v interface{}, d tpgres
190227 return v , nil
191228}
192229
193- func expandDiscoveryEngineDataConnectorEntitiesParams (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (map [string ]string , error ) {
194- if v == nil {
195- return map [string ]string {}, nil
230+ func expandDiscoveryEngineDataConnectorEntitiesParams (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
231+ b := []byte (v .(string ))
232+ if len (b ) == 0 {
233+ return nil , nil
196234 }
197- m := make (map [string ]string )
198- for k , val := range v .( map [ string ] interface {}) {
199- m [ k ] = val .( string )
235+ m := make (map [string ]interface {} )
236+ if err := json . Unmarshal ( b , & m ); err != nil {
237+ return nil , err
200238 }
201239 return m , nil
202240}
@@ -208,3 +246,23 @@ func expandDiscoveryEngineDataConnectorKmsKeyName(v interface{}, d tpgresource.T
208246func expandDiscoveryEngineDataConnectorStaticIpEnabled (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
209247 return v , nil
210248}
249+
250+ func expandDiscoveryEngineDataConnectorConnectorModes (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
251+ return v , nil
252+ }
253+
254+ func expandDiscoveryEngineDataConnectorSyncMode (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
255+ return v , nil
256+ }
257+
258+ func expandDiscoveryEngineDataConnectorIncrementalRefreshInterval (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
259+ return v , nil
260+ }
261+
262+ func expandDiscoveryEngineDataConnectorAutoRunDisabled (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
263+ return v , nil
264+ }
265+
266+ func expandDiscoveryEngineDataConnectorIncrementalSyncDisabled (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
267+ return v , nil
268+ }
0 commit comments