@@ -166,17 +166,33 @@ func ResourceMonitoringUptimeCheckConfig() *schema.Resource {
166
166
MaxItems : 1 ,
167
167
Elem : & schema.Resource {
168
168
Schema : map [string ]* schema.Schema {
169
- "password" : {
170
- Type : schema .TypeString ,
171
- Required : true ,
172
- Description : `The password to authenticate.` ,
173
- Sensitive : true ,
174
- },
175
169
"username" : {
176
170
Type : schema .TypeString ,
177
171
Required : true ,
178
172
Description : `The username to authenticate.` ,
179
173
},
174
+ "password" : {
175
+ Type : schema .TypeString ,
176
+ Optional : true ,
177
+ Description : `The password to authenticate.` ,
178
+ Sensitive : true ,
179
+ ExactlyOneOf : []string {},
180
+ },
181
+ "password_wo" : {
182
+ Type : schema .TypeString ,
183
+ Optional : true ,
184
+ Description : `The password to authenticate.` ,
185
+ WriteOnly : true ,
186
+ ExactlyOneOf : []string {},
187
+ RequiredWith : []string {"http_check.0.auth_info.0.password_wo_version" },
188
+ },
189
+ "password_wo_version" : {
190
+ Type : schema .TypeString ,
191
+ Optional : true ,
192
+ ForceNew : true ,
193
+ Description : `The password write-only version.` ,
194
+ RequiredWith : []string {"http_check.0.auth_info.0.password_wo" },
195
+ },
180
196
},
181
197
},
182
198
AtLeastOneOf : []string {"http_check.0.auth_info" , "http_check.0.port" , "http_check.0.headers" , "http_check.0.path" , "http_check.0.use_ssl" , "http_check.0.mask_headers" },
@@ -525,6 +541,11 @@ func resourceMonitoringUptimeCheckConfigCreate(d *schema.ResourceData, meta inte
525
541
obj ["syntheticMonitor" ] = syntheticMonitorProp
526
542
}
527
543
544
+ obj , err = resourceMonitoringUptimeCheckConfigEncoder (d , meta , obj )
545
+ if err != nil {
546
+ return err
547
+ }
548
+
528
549
lockName , err := tpgresource .ReplaceVars (d , config , "stackdriver/groups/{{project}}" )
529
550
if err != nil {
530
551
return err
@@ -754,6 +775,11 @@ func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta inte
754
775
obj ["tcpCheck" ] = tcpCheckProp
755
776
}
756
777
778
+ obj , err = resourceMonitoringUptimeCheckConfigEncoder (d , meta , obj )
779
+ if err != nil {
780
+ return err
781
+ }
782
+
757
783
lockName , err := tpgresource .ReplaceVars (d , config , "stackdriver/groups/{{project}}" )
758
784
if err != nil {
759
785
return err
@@ -1054,6 +1080,8 @@ func flattenMonitoringUptimeCheckConfigHttpCheckAuthInfo(v interface{}, d *schem
1054
1080
transformed := make (map [string ]interface {})
1055
1081
transformed ["password" ] =
1056
1082
flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoPassword (original ["password" ], d , config )
1083
+ transformed ["password_wo_version" ] =
1084
+ flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWoVersion (original ["passwordWoVersion" ], d , config )
1057
1085
transformed ["username" ] =
1058
1086
flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername (original ["username" ], d , config )
1059
1087
return []interface {}{transformed }
@@ -1062,6 +1090,10 @@ func flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoPassword(v interface{},
1062
1090
return d .Get ("http_check.0.auth_info.0.password" )
1063
1091
}
1064
1092
1093
+ func flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWoVersion (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1094
+ return d .Get ("http_check.0.auth_info.0.password_wo_version" )
1095
+ }
1096
+
1065
1097
func flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1066
1098
return v
1067
1099
}
@@ -1580,6 +1612,20 @@ func expandMonitoringUptimeCheckConfigHttpCheckAuthInfo(v interface{}, d tpgreso
1580
1612
transformed ["password" ] = transformedPassword
1581
1613
}
1582
1614
1615
+ transformedPasswordWo , err := expandMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWo (original ["password_wo" ], d , config )
1616
+ if err != nil {
1617
+ return nil , err
1618
+ } else if val := reflect .ValueOf (transformedPasswordWo ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1619
+ transformed ["passwordWo" ] = transformedPasswordWo
1620
+ }
1621
+
1622
+ transformedPasswordWoVersion , err := expandMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWoVersion (original ["password_wo_version" ], d , config )
1623
+ if err != nil {
1624
+ return nil , err
1625
+ } else if val := reflect .ValueOf (transformedPasswordWoVersion ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1626
+ transformed ["passwordWoVersion" ] = transformedPasswordWoVersion
1627
+ }
1628
+
1583
1629
transformedUsername , err := expandMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername (original ["username" ], d , config )
1584
1630
if err != nil {
1585
1631
return nil , err
@@ -1594,6 +1640,14 @@ func expandMonitoringUptimeCheckConfigHttpCheckAuthInfoPassword(v interface{}, d
1594
1640
return v , nil
1595
1641
}
1596
1642
1643
+ func expandMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWo (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1644
+ return v , nil
1645
+ }
1646
+
1647
+ func expandMonitoringUptimeCheckConfigHttpCheckAuthInfoPasswordWoVersion (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1648
+ return v , nil
1649
+ }
1650
+
1597
1651
func expandMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1598
1652
return v , nil
1599
1653
}
@@ -1885,3 +1939,21 @@ func expandMonitoringUptimeCheckConfigSyntheticMonitorCloudFunctionV2(v interfac
1885
1939
func expandMonitoringUptimeCheckConfigSyntheticMonitorCloudFunctionV2Name (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1886
1940
return v , nil
1887
1941
}
1942
+
1943
+ func resourceMonitoringUptimeCheckConfigEncoder (d * schema.ResourceData , meta interface {}, obj map [string ]interface {}) (map [string ]interface {}, error ) {
1944
+ // remove passwordWoVersion from the request body
1945
+ if v , ok := obj ["httpCheck" ]; ok {
1946
+ httpCheck := v .(map [string ]interface {})
1947
+ if authInfo , ok := httpCheck ["authInfo" ].(map [string ]interface {}); ok {
1948
+ delete (authInfo , "passwordWoVersion" )
1949
+ if len (authInfo ) > 0 {
1950
+ httpCheck ["authInfo" ] = authInfo
1951
+ } else {
1952
+ delete (httpCheck , "authInfo" )
1953
+ }
1954
+ obj ["httpCheck" ] = httpCheck
1955
+ }
1956
+ }
1957
+
1958
+ return obj , nil
1959
+ }
0 commit comments