Skip to content

Commit 00215db

Browse files
make connector entities mutable (#15390) (#10895)
[upstream:87fe305e57db9ffce66e0907c8198aebfb1d55ff] Signed-off-by: Modular Magician <[email protected]>
1 parent e5b7777 commit 00215db

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

.changelog/15390.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
unknown: make connector entities mutable

google-beta/services/discoveryengine/resource_discovery_engine_data_connector.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
3939
)
4040

41-
func DataConnectorEntitiesParamsDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
41+
func DataConnectorEntitiesFieldsDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
4242
return (old == "" && new == "{}") || (old == "{}" && new == "")
4343
}
4444

@@ -134,21 +134,22 @@ sync will be disabled.`,
134134
"entities": {
135135
Type: schema.TypeList,
136136
Optional: true,
137-
ForceNew: true,
138137
Description: `List of entities from the connected data source to ingest.`,
139138
Elem: &schema.Resource{
140139
Schema: map[string]*schema.Schema{
141140
"entity_name": {
142141
Type: schema.TypeString,
143142
Optional: true,
143+
ForceNew: true,
144144
Description: `The name of the entity. Supported values by data source:
145145
* Salesforce: 'Lead', 'Opportunity', 'Contact', 'Account', 'Case', 'Contract', 'Campaign'
146146
* Jira: project, issue, attachment, comment, worklog
147147
* Confluence: 'Content', 'Space'`,
148148
},
149149
"key_property_mappings": {
150-
Type: schema.TypeMap,
151-
Optional: true,
150+
Type: schema.TypeMap,
151+
Optional: true,
152+
DiffSuppressFunc: DataConnectorEntitiesFieldsDiffSuppress,
152153
Description: `Attributes for indexing.
153154
Key: Field name.
154155
Value: The key property to map a field to, such as 'title', and
@@ -163,7 +164,7 @@ Value: The key property to map a field to, such as 'title', and
163164
Type: schema.TypeString,
164165
Optional: true,
165166
ValidateFunc: validation.StringIsJSON,
166-
DiffSuppressFunc: DataConnectorEntitiesParamsDiffSuppress,
167+
DiffSuppressFunc: DataConnectorEntitiesFieldsDiffSuppress,
167168
StateFunc: func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s },
168169
Description: `The parameters for the entity to facilitate data ingestion.`,
169170
},
@@ -623,6 +624,12 @@ func resourceDiscoveryEngineDataConnectorUpdate(d *schema.ResourceData, meta int
623624
} else if v, ok := d.GetOkExists("refresh_interval"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, refreshIntervalProp)) {
624625
obj["refreshInterval"] = refreshIntervalProp
625626
}
627+
entitiesProp, err := expandDiscoveryEngineDataConnectorEntities(d.Get("entities"), d, config)
628+
if err != nil {
629+
return err
630+
} else if v, ok := d.GetOkExists("entities"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, entitiesProp)) {
631+
obj["entities"] = entitiesProp
632+
}
626633
connectorModesProp, err := expandDiscoveryEngineDataConnectorConnectorModes(d.Get("connector_modes"), d, config)
627634
if err != nil {
628635
return err
@@ -675,6 +682,11 @@ func resourceDiscoveryEngineDataConnectorUpdate(d *schema.ResourceData, meta int
675682
updateMask = append(updateMask, "refreshInterval")
676683
}
677684

685+
if d.HasChange("entities") {
686+
updateMask = append(updateMask, "entities.params",
687+
"entities.keyPropertyMappings")
688+
}
689+
678690
if d.HasChange("connector_modes") {
679691
updateMask = append(updateMask, "connectorModes")
680692
}

google-beta/services/discoveryengine/resource_discovery_engine_data_connector_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ resource "google_discovery_engine_data_connector" "servicenow-basic" {
142142
params = jsonencode({
143143
"inclusion_filters": {
144144
"knowledgeBaseSysId": [
145-
"123"
145+
"456"
146146
]
147147
}
148148
})
@@ -152,7 +152,7 @@ resource "google_discovery_engine_data_connector" "servicenow-basic" {
152152
params = jsonencode({
153153
"inclusion_filters": {
154154
"knowledgeBaseSysId": [
155-
"123"
155+
"456"
156156
]
157157
}
158158
})
@@ -162,7 +162,7 @@ resource "google_discovery_engine_data_connector" "servicenow-basic" {
162162
params = jsonencode({
163163
"inclusion_filters": {
164164
"knowledgeBaseSysId": [
165-
"123"
165+
"456"
166166
]
167167
}
168168
})
@@ -200,7 +200,7 @@ func TestAccDiscoveryEngineDataConnector_DataConnectorEntitiesParamsDiffSuppress
200200
}
201201

202202
for tn, tc := range cases {
203-
if discoveryengine.DataConnectorEntitiesParamsDiffSuppress("entities_params_diff_supress", tc.Old, tc.New, nil) != tc.ExpectDiffSuppress {
203+
if discoveryengine.DataConnectorEntitiesFieldsDiffSuppress("entities_params_diff_supress", tc.Old, tc.New, nil) != tc.ExpectDiffSuppress {
204204
t.Errorf("bad: %s, %q => %q expect DiffSuppress to return %t", tn, tc.Old, tc.New, tc.ExpectDiffSuppress)
205205
}
206206
}

0 commit comments

Comments
 (0)