@@ -58,6 +58,64 @@ func ResourceDialogflowCXFlow() *schema.Resource {
58
58
Required : true ,
59
59
Description : `The human-readable name of the flow.` ,
60
60
},
61
+ "advanced_settings" : {
62
+ Type : schema .TypeList ,
63
+ Optional : true ,
64
+ Description : `Hierarchical advanced settings for this flow. The settings exposed at the lower level overrides the settings exposed at the higher level.
65
+ Hierarchy: Agent->Flow->Page->Fulfillment/Parameter.` ,
66
+ MaxItems : 1 ,
67
+ Elem : & schema.Resource {
68
+ Schema : map [string ]* schema.Schema {
69
+ "audio_export_gcs_destination" : {
70
+ Type : schema .TypeList ,
71
+ Optional : true ,
72
+ Description : `If present, incoming audio is exported by Dialogflow to the configured Google Cloud Storage destination. Exposed at the following levels:
73
+ * Agent level
74
+ * Flow level` ,
75
+ MaxItems : 1 ,
76
+ Elem : & schema.Resource {
77
+ Schema : map [string ]* schema.Schema {
78
+ "uri" : {
79
+ Type : schema .TypeString ,
80
+ Optional : true ,
81
+ Description : `The Google Cloud Storage URI for the exported objects. Whether a full object name, or just a prefix, its usage depends on the Dialogflow operation.
82
+ Format: gs://bucket/object-name-or-prefix` ,
83
+ },
84
+ },
85
+ },
86
+ },
87
+ "dtmf_settings" : {
88
+ Type : schema .TypeList ,
89
+ Optional : true ,
90
+ Description : `Define behaviors for DTMF (dual tone multi frequency). DTMF settings does not override each other. DTMF settings set at different levels define DTMF detections running in parallel. Exposed at the following levels:
91
+ * Agent level
92
+ * Flow level
93
+ * Page level
94
+ * Parameter level` ,
95
+ MaxItems : 1 ,
96
+ Elem : & schema.Resource {
97
+ Schema : map [string ]* schema.Schema {
98
+ "enabled" : {
99
+ Type : schema .TypeBool ,
100
+ Optional : true ,
101
+ Description : `If true, incoming audio is processed for DTMF (dual tone multi frequency) events. For example, if the caller presses a button on their telephone keypad and DTMF processing is enabled, Dialogflow will detect the event (e.g. a "3" was pressed) in the incoming audio and pass the event to the bot to drive business logic (e.g. when 3 is pressed, return the account balance).` ,
102
+ },
103
+ "finish_digit" : {
104
+ Type : schema .TypeString ,
105
+ Optional : true ,
106
+ Description : `The digit that terminates a DTMF digit sequence.` ,
107
+ },
108
+ "max_digits" : {
109
+ Type : schema .TypeInt ,
110
+ Optional : true ,
111
+ Description : `Max length of DTMF digits.` ,
112
+ },
113
+ },
114
+ },
115
+ },
116
+ },
117
+ },
118
+ },
61
119
"description" : {
62
120
Type : schema .TypeString ,
63
121
Optional : true ,
@@ -678,6 +736,12 @@ func resourceDialogflowCXFlowCreate(d *schema.ResourceData, meta interface{}) er
678
736
} else if v , ok := d .GetOkExists ("nlu_settings" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (nluSettingsProp )) && (ok || ! reflect .DeepEqual (v , nluSettingsProp )) {
679
737
obj ["nluSettings" ] = nluSettingsProp
680
738
}
739
+ advancedSettingsProp , err := expandDialogflowCXFlowAdvancedSettings (d .Get ("advanced_settings" ), d , config )
740
+ if err != nil {
741
+ return err
742
+ } else if v , ok := d .GetOkExists ("advanced_settings" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (advancedSettingsProp )) && (ok || ! reflect .DeepEqual (v , advancedSettingsProp )) {
743
+ obj ["advancedSettings" ] = advancedSettingsProp
744
+ }
681
745
languageCodeProp , err := expandDialogflowCXFlowLanguageCode (d .Get ("language_code" ), d , config )
682
746
if err != nil {
683
747
return err
@@ -805,6 +869,9 @@ func resourceDialogflowCXFlowRead(d *schema.ResourceData, meta interface{}) erro
805
869
if err := d .Set ("nlu_settings" , flattenDialogflowCXFlowNluSettings (res ["nluSettings" ], d , config )); err != nil {
806
870
return fmt .Errorf ("Error reading Flow: %s" , err )
807
871
}
872
+ if err := d .Set ("advanced_settings" , flattenDialogflowCXFlowAdvancedSettings (res ["advancedSettings" ], d , config )); err != nil {
873
+ return fmt .Errorf ("Error reading Flow: %s" , err )
874
+ }
808
875
if err := d .Set ("language_code" , flattenDialogflowCXFlowLanguageCode (res ["languageCode" ], d , config )); err != nil {
809
876
return fmt .Errorf ("Error reading Flow: %s" , err )
810
877
}
@@ -858,6 +925,12 @@ func resourceDialogflowCXFlowUpdate(d *schema.ResourceData, meta interface{}) er
858
925
} else if v , ok := d .GetOkExists ("nlu_settings" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , nluSettingsProp )) {
859
926
obj ["nluSettings" ] = nluSettingsProp
860
927
}
928
+ advancedSettingsProp , err := expandDialogflowCXFlowAdvancedSettings (d .Get ("advanced_settings" ), d , config )
929
+ if err != nil {
930
+ return err
931
+ } else if v , ok := d .GetOkExists ("advanced_settings" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , advancedSettingsProp )) {
932
+ obj ["advancedSettings" ] = advancedSettingsProp
933
+ }
861
934
862
935
url , err := tpgresource .ReplaceVars (d , config , "{{DialogflowCXBasePath}}{{parent}}/flows/{{name}}" )
863
936
if err != nil {
@@ -890,6 +963,10 @@ func resourceDialogflowCXFlowUpdate(d *schema.ResourceData, meta interface{}) er
890
963
if d .HasChange ("nlu_settings" ) {
891
964
updateMask = append (updateMask , "nluSettings" )
892
965
}
966
+
967
+ if d .HasChange ("advanced_settings" ) {
968
+ updateMask = append (updateMask , "advancedSettings" )
969
+ }
893
970
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
894
971
// won't set it
895
972
url , err = transport_tpg .AddQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -1710,6 +1787,80 @@ func flattenDialogflowCXFlowNluSettingsModelTrainingMode(v interface{}, d *schem
1710
1787
return v
1711
1788
}
1712
1789
1790
+ func flattenDialogflowCXFlowAdvancedSettings (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1791
+ if v == nil {
1792
+ return nil
1793
+ }
1794
+ original := v .(map [string ]interface {})
1795
+ if len (original ) == 0 {
1796
+ return nil
1797
+ }
1798
+ transformed := make (map [string ]interface {})
1799
+ transformed ["audio_export_gcs_destination" ] =
1800
+ flattenDialogflowCXFlowAdvancedSettingsAudioExportGcsDestination (original ["audioExportGcsDestination" ], d , config )
1801
+ transformed ["dtmf_settings" ] =
1802
+ flattenDialogflowCXFlowAdvancedSettingsDtmfSettings (original ["dtmfSettings" ], d , config )
1803
+ return []interface {}{transformed }
1804
+ }
1805
+ func flattenDialogflowCXFlowAdvancedSettingsAudioExportGcsDestination (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1806
+ if v == nil {
1807
+ return nil
1808
+ }
1809
+ original := v .(map [string ]interface {})
1810
+ if len (original ) == 0 {
1811
+ return nil
1812
+ }
1813
+ transformed := make (map [string ]interface {})
1814
+ transformed ["uri" ] =
1815
+ flattenDialogflowCXFlowAdvancedSettingsAudioExportGcsDestinationUri (original ["uri" ], d , config )
1816
+ return []interface {}{transformed }
1817
+ }
1818
+ func flattenDialogflowCXFlowAdvancedSettingsAudioExportGcsDestinationUri (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1819
+ return v
1820
+ }
1821
+
1822
+ func flattenDialogflowCXFlowAdvancedSettingsDtmfSettings (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1823
+ if v == nil {
1824
+ return nil
1825
+ }
1826
+ original := v .(map [string ]interface {})
1827
+ if len (original ) == 0 {
1828
+ return nil
1829
+ }
1830
+ transformed := make (map [string ]interface {})
1831
+ transformed ["enabled" ] =
1832
+ flattenDialogflowCXFlowAdvancedSettingsDtmfSettingsEnabled (original ["enabled" ], d , config )
1833
+ transformed ["max_digits" ] =
1834
+ flattenDialogflowCXFlowAdvancedSettingsDtmfSettingsMaxDigits (original ["maxDigits" ], d , config )
1835
+ transformed ["finish_digit" ] =
1836
+ flattenDialogflowCXFlowAdvancedSettingsDtmfSettingsFinishDigit (original ["finishDigit" ], d , config )
1837
+ return []interface {}{transformed }
1838
+ }
1839
+ func flattenDialogflowCXFlowAdvancedSettingsDtmfSettingsEnabled (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1840
+ return v
1841
+ }
1842
+
1843
+ func flattenDialogflowCXFlowAdvancedSettingsDtmfSettingsMaxDigits (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1844
+ // Handles the string fixed64 format
1845
+ if strVal , ok := v .(string ); ok {
1846
+ if intVal , err := tpgresource .StringToFixed64 (strVal ); err == nil {
1847
+ return intVal
1848
+ }
1849
+ }
1850
+
1851
+ // number values are represented as float64
1852
+ if floatVal , ok := v .(float64 ); ok {
1853
+ intVal := int (floatVal )
1854
+ return intVal
1855
+ }
1856
+
1857
+ return v // let terraform core handle it otherwise
1858
+ }
1859
+
1860
+ func flattenDialogflowCXFlowAdvancedSettingsDtmfSettingsFinishDigit (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1861
+ return v
1862
+ }
1863
+
1713
1864
func flattenDialogflowCXFlowLanguageCode (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1714
1865
return v
1715
1866
}
@@ -2774,6 +2925,100 @@ func expandDialogflowCXFlowNluSettingsModelTrainingMode(v interface{}, d tpgreso
2774
2925
return v , nil
2775
2926
}
2776
2927
2928
+ func expandDialogflowCXFlowAdvancedSettings (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2929
+ l := v .([]interface {})
2930
+ if len (l ) == 0 || l [0 ] == nil {
2931
+ return nil , nil
2932
+ }
2933
+ raw := l [0 ]
2934
+ original := raw .(map [string ]interface {})
2935
+ transformed := make (map [string ]interface {})
2936
+
2937
+ transformedAudioExportGcsDestination , err := expandDialogflowCXFlowAdvancedSettingsAudioExportGcsDestination (original ["audio_export_gcs_destination" ], d , config )
2938
+ if err != nil {
2939
+ return nil , err
2940
+ } else if val := reflect .ValueOf (transformedAudioExportGcsDestination ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2941
+ transformed ["audioExportGcsDestination" ] = transformedAudioExportGcsDestination
2942
+ }
2943
+
2944
+ transformedDtmfSettings , err := expandDialogflowCXFlowAdvancedSettingsDtmfSettings (original ["dtmf_settings" ], d , config )
2945
+ if err != nil {
2946
+ return nil , err
2947
+ } else if val := reflect .ValueOf (transformedDtmfSettings ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2948
+ transformed ["dtmfSettings" ] = transformedDtmfSettings
2949
+ }
2950
+
2951
+ return transformed , nil
2952
+ }
2953
+
2954
+ func expandDialogflowCXFlowAdvancedSettingsAudioExportGcsDestination (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2955
+ l := v .([]interface {})
2956
+ if len (l ) == 0 || l [0 ] == nil {
2957
+ return nil , nil
2958
+ }
2959
+ raw := l [0 ]
2960
+ original := raw .(map [string ]interface {})
2961
+ transformed := make (map [string ]interface {})
2962
+
2963
+ transformedUri , err := expandDialogflowCXFlowAdvancedSettingsAudioExportGcsDestinationUri (original ["uri" ], d , config )
2964
+ if err != nil {
2965
+ return nil , err
2966
+ } else if val := reflect .ValueOf (transformedUri ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2967
+ transformed ["uri" ] = transformedUri
2968
+ }
2969
+
2970
+ return transformed , nil
2971
+ }
2972
+
2973
+ func expandDialogflowCXFlowAdvancedSettingsAudioExportGcsDestinationUri (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2974
+ return v , nil
2975
+ }
2976
+
2977
+ func expandDialogflowCXFlowAdvancedSettingsDtmfSettings (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2978
+ l := v .([]interface {})
2979
+ if len (l ) == 0 || l [0 ] == nil {
2980
+ return nil , nil
2981
+ }
2982
+ raw := l [0 ]
2983
+ original := raw .(map [string ]interface {})
2984
+ transformed := make (map [string ]interface {})
2985
+
2986
+ transformedEnabled , err := expandDialogflowCXFlowAdvancedSettingsDtmfSettingsEnabled (original ["enabled" ], d , config )
2987
+ if err != nil {
2988
+ return nil , err
2989
+ } else if val := reflect .ValueOf (transformedEnabled ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2990
+ transformed ["enabled" ] = transformedEnabled
2991
+ }
2992
+
2993
+ transformedMaxDigits , err := expandDialogflowCXFlowAdvancedSettingsDtmfSettingsMaxDigits (original ["max_digits" ], d , config )
2994
+ if err != nil {
2995
+ return nil , err
2996
+ } else if val := reflect .ValueOf (transformedMaxDigits ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2997
+ transformed ["maxDigits" ] = transformedMaxDigits
2998
+ }
2999
+
3000
+ transformedFinishDigit , err := expandDialogflowCXFlowAdvancedSettingsDtmfSettingsFinishDigit (original ["finish_digit" ], d , config )
3001
+ if err != nil {
3002
+ return nil , err
3003
+ } else if val := reflect .ValueOf (transformedFinishDigit ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
3004
+ transformed ["finishDigit" ] = transformedFinishDigit
3005
+ }
3006
+
3007
+ return transformed , nil
3008
+ }
3009
+
3010
+ func expandDialogflowCXFlowAdvancedSettingsDtmfSettingsEnabled (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
3011
+ return v , nil
3012
+ }
3013
+
3014
+ func expandDialogflowCXFlowAdvancedSettingsDtmfSettingsMaxDigits (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
3015
+ return v , nil
3016
+ }
3017
+
3018
+ func expandDialogflowCXFlowAdvancedSettingsDtmfSettingsFinishDigit (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
3019
+ return v , nil
3020
+ }
3021
+
2777
3022
func expandDialogflowCXFlowLanguageCode (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2778
3023
return v , nil
2779
3024
}
0 commit comments