Skip to content

Commit a7317ca

Browse files
Add GenAppBuilderSettings to Dialogflow CX Agent resource (#13898) (#22757)
[upstream:fb1e861ab747ce7aaf6948227b975eb988e9277f] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 8d18636 commit a7317ca

File tree

5 files changed

+97
-0
lines changed

5 files changed

+97
-0
lines changed

.changelog/13898.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
dialogflowcx: added `genAppBuilderSettings` field to `google_dialogflow_cx_agent` resource
3+
```

google/services/dialogflowcx/resource_dialogflow_cx_agent.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,22 @@ A duration in seconds with up to nine fractional digits, ending with 's'. Exampl
231231
Deprecated: "`enable_stackdriver_logging` is deprecated and will be removed in a future major release. Please use `advanced_settings.logging_settings.enable_stackdriver_logging`instead.",
232232
Description: `Determines whether this agent should log conversation queries.`,
233233
},
234+
"gen_app_builder_settings": {
235+
Type: schema.TypeList,
236+
Optional: true,
237+
Description: `Gen App Builder-related agent-level settings.`,
238+
MaxItems: 1,
239+
Elem: &schema.Resource{
240+
Schema: map[string]*schema.Schema{
241+
"engine": {
242+
Type: schema.TypeString,
243+
Required: true,
244+
Description: `The full name of the Gen App Builder engine related to this agent if there is one.
245+
Format: projects/{Project ID}/locations/{Location ID}/collections/{Collection ID}/engines/{Engine ID}`,
246+
},
247+
},
248+
},
249+
},
234250
"git_integration_settings": {
235251
Type: schema.TypeList,
236252
Optional: true,
@@ -435,6 +451,12 @@ func resourceDialogflowCXAgentCreate(d *schema.ResourceData, meta interface{}) e
435451
} else if v, ok := d.GetOkExists("text_to_speech_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(textToSpeechSettingsProp)) && (ok || !reflect.DeepEqual(v, textToSpeechSettingsProp)) {
436452
obj["textToSpeechSettings"] = textToSpeechSettingsProp
437453
}
454+
genAppBuilderSettingsProp, err := expandDialogflowCXAgentGenAppBuilderSettings(d.Get("gen_app_builder_settings"), d, config)
455+
if err != nil {
456+
return err
457+
} else if v, ok := d.GetOkExists("gen_app_builder_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(genAppBuilderSettingsProp)) && (ok || !reflect.DeepEqual(v, genAppBuilderSettingsProp)) {
458+
obj["genAppBuilderSettings"] = genAppBuilderSettingsProp
459+
}
438460

439461
url, err := tpgresource.ReplaceVars(d, config, "{{DialogflowCXBasePath}}projects/{{project}}/locations/{{location}}/agents")
440462
if err != nil {
@@ -572,6 +594,9 @@ func resourceDialogflowCXAgentRead(d *schema.ResourceData, meta interface{}) err
572594
if err := d.Set("text_to_speech_settings", flattenDialogflowCXAgentTextToSpeechSettings(res["textToSpeechSettings"], d, config)); err != nil {
573595
return fmt.Errorf("Error reading Agent: %s", err)
574596
}
597+
if err := d.Set("gen_app_builder_settings", flattenDialogflowCXAgentGenAppBuilderSettings(res["genAppBuilderSettings"], d, config)); err != nil {
598+
return fmt.Errorf("Error reading Agent: %s", err)
599+
}
575600

576601
return nil
577602
}
@@ -664,6 +689,12 @@ func resourceDialogflowCXAgentUpdate(d *schema.ResourceData, meta interface{}) e
664689
} else if v, ok := d.GetOkExists("text_to_speech_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, textToSpeechSettingsProp)) {
665690
obj["textToSpeechSettings"] = textToSpeechSettingsProp
666691
}
692+
genAppBuilderSettingsProp, err := expandDialogflowCXAgentGenAppBuilderSettings(d.Get("gen_app_builder_settings"), d, config)
693+
if err != nil {
694+
return err
695+
} else if v, ok := d.GetOkExists("gen_app_builder_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, genAppBuilderSettingsProp)) {
696+
obj["genAppBuilderSettings"] = genAppBuilderSettingsProp
697+
}
667698

668699
url, err := tpgresource.ReplaceVars(d, config, "{{DialogflowCXBasePath}}projects/{{project}}/locations/{{location}}/agents/{{name}}")
669700
if err != nil {
@@ -721,6 +752,10 @@ func resourceDialogflowCXAgentUpdate(d *schema.ResourceData, meta interface{}) e
721752
if d.HasChange("text_to_speech_settings") {
722753
updateMask = append(updateMask, "textToSpeechSettings")
723754
}
755+
756+
if d.HasChange("gen_app_builder_settings") {
757+
updateMask = append(updateMask, "genAppBuilderSettings")
758+
}
724759
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
725760
// won't set it
726761
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
@@ -1077,6 +1112,23 @@ func flattenDialogflowCXAgentTextToSpeechSettingsSynthesizeSpeechConfigs(v inter
10771112
return string(b)
10781113
}
10791114

1115+
func flattenDialogflowCXAgentGenAppBuilderSettings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1116+
if v == nil {
1117+
return nil
1118+
}
1119+
original := v.(map[string]interface{})
1120+
if len(original) == 0 {
1121+
return nil
1122+
}
1123+
transformed := make(map[string]interface{})
1124+
transformed["engine"] =
1125+
flattenDialogflowCXAgentGenAppBuilderSettingsEngine(original["engine"], d, config)
1126+
return []interface{}{transformed}
1127+
}
1128+
func flattenDialogflowCXAgentGenAppBuilderSettingsEngine(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1129+
return v
1130+
}
1131+
10801132
func expandDialogflowCXAgentDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
10811133
return v, nil
10821134
}
@@ -1479,6 +1531,29 @@ func expandDialogflowCXAgentTextToSpeechSettingsSynthesizeSpeechConfigs(v interf
14791531
return m, nil
14801532
}
14811533

1534+
func expandDialogflowCXAgentGenAppBuilderSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1535+
l := v.([]interface{})
1536+
if len(l) == 0 || l[0] == nil {
1537+
return nil, nil
1538+
}
1539+
raw := l[0]
1540+
original := raw.(map[string]interface{})
1541+
transformed := make(map[string]interface{})
1542+
1543+
transformedEngine, err := expandDialogflowCXAgentGenAppBuilderSettingsEngine(original["engine"], d, config)
1544+
if err != nil {
1545+
return nil, err
1546+
} else if val := reflect.ValueOf(transformedEngine); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1547+
transformed["engine"] = transformedEngine
1548+
}
1549+
1550+
return transformed, nil
1551+
}
1552+
1553+
func expandDialogflowCXAgentGenAppBuilderSettingsEngine(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1554+
return v, nil
1555+
}
1556+
14821557
func resourceDialogflowCXAgentPostCreateSetComputedFields(d *schema.ResourceData, meta interface{}, res map[string]interface{}) error {
14831558
config := meta.(*transport_tpg.Config)
14841559
if err := d.Set("name", flattenDialogflowCXAgentName(res["name"], d, config)); err != nil {

google/services/dialogflowcx/resource_dialogflow_cx_agent_generated_meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ fields:
2222
- field: 'display_name'
2323
- field: 'enable_spell_correction'
2424
- field: 'enable_stackdriver_logging'
25+
- field: 'gen_app_builder_settings.engine'
2526
- field: 'git_integration_settings.github_settings.access_token'
2627
- field: 'git_integration_settings.github_settings.branches'
2728
- field: 'git_integration_settings.github_settings.display_name'

google/services/dialogflowcx/resource_dialogflow_cx_agent_generated_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ resource "google_dialogflow_cx_agent" "full_agent" {
124124
}
125125
})
126126
}
127+
gen_app_builder_settings {
128+
engine = "projects/-/locations/-/collections/-/engines/-"
129+
}
127130
}
128131
`, context)
129132
}

website/docs/r/dialogflow_cx_agent.html.markdown

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ resource "google_dialogflow_cx_agent" "full_agent" {
110110
}
111111
})
112112
}
113+
gen_app_builder_settings {
114+
engine = "projects/-/locations/-/collections/-/engines/-"
115+
}
113116
}
114117
```
115118

@@ -190,6 +193,11 @@ The following arguments are supported:
190193
Settings related to speech synthesizing.
191194
Structure is [documented below](#nested_text_to_speech_settings).
192195

196+
* `gen_app_builder_settings` -
197+
(Optional)
198+
Gen App Builder-related agent-level settings.
199+
Structure is [documented below](#nested_gen_app_builder_settings).
200+
193201
* `project` - (Optional) The ID of the project in which the resource belongs.
194202
If it is not provided, the provider project is used.
195203

@@ -329,6 +337,13 @@ The following arguments are supported:
329337
* The phone gateway synthesize configuration set via Agent.text_to_speech_settings.
330338
* How speech is synthesized when invoking session APIs. `Agent.text_to_speech_settings` only applies if `OutputAudioConfig.synthesize_speech_config` is not specified.
331339

340+
<a name="nested_gen_app_builder_settings"></a>The `gen_app_builder_settings` block supports:
341+
342+
* `engine` -
343+
(Required)
344+
The full name of the Gen App Builder engine related to this agent if there is one.
345+
Format: projects/{Project ID}/locations/{Location ID}/collections/{Collection ID}/engines/{Engine ID}
346+
332347
## Attributes Reference
333348

334349
In addition to the arguments listed above, the following computed attributes are exported:

0 commit comments

Comments
 (0)