@@ -448,6 +448,11 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac
448448 obj ["quicOverride" ] = quicOverrideProp
449449 }
450450
451+ obj , err = resourceComputeTargetHttpsProxyUpdateEncoder (d , meta , obj )
452+ if err != nil {
453+ return err
454+ }
455+
451456 url , err := tpgresource .ReplaceVars (d , config , "{{ComputeBasePath}}projects/{{project}}/global/targetHttpsProxies/{{name}}/setQuicOverride" )
452457 if err != nil {
453458 return err
@@ -496,6 +501,11 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac
496501 obj ["sslCertificates" ] = sslCertificatesProp
497502 }
498503
504+ obj , err = resourceComputeTargetHttpsProxyUpdateEncoder (d , meta , obj )
505+ if err != nil {
506+ return err
507+ }
508+
499509 url , err := tpgresource .ReplaceVars (d , config , "{{ComputeBasePath}}projects/{{project}}/targetHttpsProxies/{{name}}/setSslCertificates" )
500510 if err != nil {
501511 return err
@@ -538,6 +548,11 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac
538548 obj ["certificateMap" ] = certificateMapProp
539549 }
540550
551+ obj , err = resourceComputeTargetHttpsProxyUpdateEncoder (d , meta , obj )
552+ if err != nil {
553+ return err
554+ }
555+
541556 url , err := tpgresource .ReplaceVars (d , config , "{{ComputeBasePath}}projects/{{project}}/global/targetHttpsProxies/{{name}}/setCertificateMap" )
542557 if err != nil {
543558 return err
@@ -580,6 +595,11 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac
580595 obj ["sslPolicy" ] = sslPolicyProp
581596 }
582597
598+ obj , err = resourceComputeTargetHttpsProxyUpdateEncoder (d , meta , obj )
599+ if err != nil {
600+ return err
601+ }
602+
583603 url , err := tpgresource .ReplaceVars (d , config , "{{ComputeBasePath}}projects/{{project}}/global/targetHttpsProxies/{{name}}/setSslPolicy" )
584604 if err != nil {
585605 return err
@@ -622,6 +642,11 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac
622642 obj ["urlMap" ] = urlMapProp
623643 }
624644
645+ obj , err = resourceComputeTargetHttpsProxyUpdateEncoder (d , meta , obj )
646+ if err != nil {
647+ return err
648+ }
649+
625650 url , err := tpgresource .ReplaceVars (d , config , "{{ComputeBasePath}}projects/{{project}}/targetHttpsProxies/{{name}}/setUrlMap" )
626651 if err != nil {
627652 return err
@@ -925,6 +950,19 @@ func resourceComputeTargetHttpsProxyEncoder(d *schema.ResourceData, meta interfa
925950 return obj , nil
926951}
927952
953+ func resourceComputeTargetHttpsProxyUpdateEncoder (d * schema.ResourceData , meta interface {}, obj map [string ]interface {}) (map [string ]interface {}, error ) {
954+
955+ if _ , ok := obj ["certificateManagerCertificates" ]; ok {
956+ // The field certificateManagerCertificates should not be included in the API request, and it should be renamed to `sslCertificates`
957+ // The API does not allow using both certificate manager certificates and sslCertificates. If that changes
958+ // in the future, the encoder logic should change accordingly because this will mean that both fields are no longer mutual exclusive.
959+ log .Printf ("[DEBUG] converting the field CertificateManagerCertificates to sslCertificates before sending the request" )
960+ obj ["sslCertificates" ] = obj ["certificateManagerCertificates" ]
961+ delete (obj , "certificateManagerCertificates" )
962+ }
963+ return obj , nil
964+ }
965+
928966func resourceComputeTargetHttpsProxyDecoder (d * schema.ResourceData , meta interface {}, res map [string ]interface {}) (map [string ]interface {}, error ) {
929967 // Since both sslCertificates and certificateManagerCertificates maps to the same API field (sslCertificates), we need to check the types
930968 // of certificates that exist in the array and decide whether to change the field to certificateManagerCertificate or not.
0 commit comments