@@ -34,7 +34,7 @@ type AccountSSLSettingsDTOResponse struct {
3434}
3535
3636// UpdateAccountSSLSettings update account SSL settings
37- func (c * Client ) UpdateAccountSSLSettings (accountSSLSettingsDTO * AccountSSLSettingsDTO , accountId int ) (* AccountSSLSettingsDTOResponse , diag.Diagnostics ) {
37+ func (c * Client ) UpdateAccountSSLSettings (accountSSLSettingsDTO * AccountSSLSettingsDTO , accountId string ) (* AccountSSLSettingsDTOResponse , diag.Diagnostics ) {
3838 var diags diag.Diagnostics
3939 log .Printf ("[INFO] updating account SSL settings to: %v " , accountSSLSettingsDTO )
4040
@@ -44,7 +44,7 @@ func (c *Client) UpdateAccountSSLSettings(accountSSLSettingsDTO *AccountSSLSetti
4444 diags = append (diags , diag.Diagnostic {
4545 Severity : diag .Error ,
4646 Summary : "Unable to parse update account SSL settings properties" ,
47- Detail : fmt .Sprintf ("Failed to parse update account SSL settings properties for account id %d , %s" , accountId , err .Error ()),
47+ Detail : fmt .Sprintf ("Failed to parse update account SSL settings properties for account id %s , %s" , accountId , err .Error ()),
4848 })
4949 return nil , diags
5050 }
@@ -53,7 +53,7 @@ func (c *Client) UpdateAccountSSLSettings(accountSSLSettingsDTO *AccountSSLSetti
5353 diags = append (diags , diag.Diagnostic {
5454 Severity : diag .Error ,
5555 Summary : "Error response from Imperva service on update account SSL settings" ,
56- Detail : fmt .Sprintf ("Failed to update account SSL settings for account id %d , %s" , accountId , err .Error ()),
56+ Detail : fmt .Sprintf ("Failed to update account SSL settings for account id %s , %s" , accountId , err .Error ()),
5757 })
5858 return nil , diags
5959 }
@@ -63,7 +63,7 @@ func (c *Client) UpdateAccountSSLSettings(accountSSLSettingsDTO *AccountSSLSetti
6363 diags = append (diags , diag.Diagnostic {
6464 Severity : diag .Error ,
6565 Summary : "Failed to read response from Imperva service on update account SSL settings" ,
66- Detail : fmt .Sprintf ("Failed to read response for account id %d , %s" , accountId , err .Error ()),
66+ Detail : fmt .Sprintf ("Failed to read response for account id %s , %s" , accountId , err .Error ()),
6767 })
6868 return nil , diags
6969 }
@@ -72,7 +72,7 @@ func (c *Client) UpdateAccountSSLSettings(accountSSLSettingsDTO *AccountSSLSetti
7272 diags = append (diags , diag.Diagnostic {
7373 Severity : diag .Error ,
7474 Summary : "Failed to read response from Imperva service on update account SSL settings" ,
75- Detail : fmt .Sprintf ("Failed to read response for account id %d , got response status %d, %s" , accountId , resp .StatusCode , string (responseBody )),
75+ Detail : fmt .Sprintf ("Failed to read response for account id %s , got response status %d, %s" , accountId , resp .StatusCode , string (responseBody )),
7676 })
7777 return nil , diags
7878 }
@@ -82,28 +82,28 @@ func (c *Client) UpdateAccountSSLSettings(accountSSLSettingsDTO *AccountSSLSetti
8282 diags = append (diags , diag.Diagnostic {
8383 Severity : diag .Error ,
8484 Summary : "Failed to parse update account SSL settings response" ,
85- Detail : fmt .Sprintf ("Failed to parse update account SSL settings JSON response for account %d , %s" , accountId , err .Error ()),
85+ Detail : fmt .Sprintf ("Failed to parse update account SSL settings JSON response for account %s , %s" , accountId , err .Error ()),
8686 })
8787 return nil , diags
8888 }
8989
90- log .Printf ("[DEBUG] Imperva update account SSL settings ended successfully for account id: %d " , accountId )
90+ log .Printf ("[DEBUG] Imperva update account SSL settings ended successfully for account id: %s " , accountId )
9191
9292 return & accountSSLSettingsDTOResponse , nil
9393}
9494
9595// GetAccountSSLSettings gets the Incapsula managed account's status
96- func (c * Client ) GetAccountSSLSettings (accountId int ) (* AccountSSLSettingsDTOResponse , diag.Diagnostics ) {
96+ func (c * Client ) GetAccountSSLSettings (accountId string ) (* AccountSSLSettingsDTOResponse , diag.Diagnostics ) {
9797 var diags diag.Diagnostics
98- log .Printf ("[INFO] Getting account SSL settings of: %d " , accountId )
98+ log .Printf ("[INFO] Getting account SSL settings of: %s " , accountId )
9999
100100 getUrl := getUrl (accountId , c .config .BaseURLAPI )
101101 resp , err := c .DoJsonAndQueryParamsRequestWithHeaders (http .MethodGet , getUrl , nil , nil , GetAccountSSLSettings )
102102 if err != nil {
103103 diags = append (diags , diag.Diagnostic {
104104 Severity : diag .Error ,
105105 Summary : "Error response from Imperva service on getting account SSL settings" ,
106- Detail : fmt .Sprintf ("Failed to get account SSL settings for account id %d , %s" , accountId , err .Error ()),
106+ Detail : fmt .Sprintf ("Failed to get account SSL settings for account id %s , %s" , accountId , err .Error ()),
107107 })
108108 return nil , diags
109109 }
@@ -114,17 +114,17 @@ func (c *Client) GetAccountSSLSettings(accountId int) (*AccountSSLSettingsDTORes
114114 diags = append (diags , diag.Diagnostic {
115115 Severity : diag .Error ,
116116 Summary : "Failed to read response from Imperva service on getting account SSL settings" ,
117- Detail : fmt .Sprintf ("Failed to read response for account id %d , %s" , accountId , err .Error ()),
117+ Detail : fmt .Sprintf ("Failed to read response for account id %s , %s" , accountId , err .Error ()),
118118 })
119119 return nil , diags
120120 }
121121
122- log .Printf ("[DEBUG] Imperva get account SSL settings for account %d response: %s\n " , accountId , string (responseBody ))
122+ log .Printf ("[DEBUG] Imperva get account SSL settings for account %s response: %s\n " , accountId , string (responseBody ))
123123 if resp .StatusCode != 200 {
124124 diags = append (diags , diag.Diagnostic {
125125 Severity : diag .Error ,
126126 Summary : "Failed to read response from Imperva service on getting account SSL settings" ,
127- Detail : fmt .Sprintf ("Failed to read response for account id %d , got response status %d, %s" , accountId , resp .StatusCode , string (responseBody )),
127+ Detail : fmt .Sprintf ("Failed to read response for account id %s , got response status %d, %s" , accountId , resp .StatusCode , string (responseBody )),
128128 })
129129 return nil , diags
130130 }
@@ -134,49 +134,49 @@ func (c *Client) GetAccountSSLSettings(accountId int) (*AccountSSLSettingsDTORes
134134 diags = append (diags , diag.Diagnostic {
135135 Severity : diag .Error ,
136136 Summary : "Failed to parse get account SSL settings response" ,
137- Detail : fmt .Sprintf ("Failed to parse get account SSL settings JSON response for account %d , %s" , accountId , err .Error ()),
137+ Detail : fmt .Sprintf ("Failed to parse get account SSL settings JSON response for account %s , %s" , accountId , err .Error ()),
138138 })
139139 return nil , diags
140140 }
141- log .Printf ("[DEBUG] get account SSL settings ended successfully for account id: %d " , accountId )
141+ log .Printf ("[DEBUG] get account SSL settings ended successfully for account id: %s " , accountId )
142142 return & accountSSLSettingsDTOResponse , nil
143143}
144144
145145// DeleteAccountSSLSettings gets the Incapsula managed account's status
146- func (c * Client ) DeleteAccountSSLSettings (accountId int ) diag.Diagnostics {
146+ func (c * Client ) DeleteAccountSSLSettings (accountId string ) diag.Diagnostics {
147147 var diags diag.Diagnostics
148- log .Printf ("[INFO] Reseting account SSL settings of: %d " , accountId )
148+ log .Printf ("[INFO] Reseting account SSL settings of: %s " , accountId )
149149
150150 getUrl := getUrl (accountId , c .config .BaseURLAPI )
151151 resp , err := c .DoJsonAndQueryParamsRequestWithHeaders (http .MethodDelete , getUrl , nil , nil , DeleteAccountSSLSettings )
152152 if err != nil {
153153 diags = append (diags , diag.Diagnostic {
154154 Severity : diag .Error ,
155155 Summary : "Failed to delete account SSL settings" ,
156- Detail : fmt .Sprintf ("error from Imperva service when deleting Account SSL certificate for account_id %d : %s" , accountId , err .Error ()),
156+ Detail : fmt .Sprintf ("error from Imperva service when deleting Account SSL certificate for account_id %s : %s" , accountId , err .Error ()),
157157 })
158158 return diags
159159 }
160160
161161 // Read the body
162162 defer resp .Body .Close ()
163163
164- log .Printf ("[DEBUG] delete account SSL settings ended successfully for account id: %d " , accountId )
164+ log .Printf ("[DEBUG] delete account SSL settings ended successfully for account id: %s " , accountId )
165165 if resp .StatusCode != 200 {
166166 diags = append (diags , diag.Diagnostic {
167167 Severity : diag .Error ,
168168 Summary : "Failed to read response from Imperva service on update account SSL settings" ,
169- Detail : fmt .Sprintf ("Failed to read response for account id %d , got response status %d" , accountId , resp .StatusCode ),
169+ Detail : fmt .Sprintf ("Failed to read response for account id %s , got response status %d" , accountId , resp .StatusCode ),
170170 })
171171 return diags
172172 }
173173 return nil
174174}
175175
176- func getUrl (accountId int , baseUrl string ) string {
176+ func getUrl (accountId string , baseUrl string ) string {
177177 url := fmt .Sprintf ("%s%s" , baseUrl , accountSSLSettingsUrl )
178- if accountId > 0 {
179- url = fmt .Sprintf ("%s%s?caid=%d " , baseUrl , accountSSLSettingsUrl , accountId )
178+ if accountId != "" {
179+ url = fmt .Sprintf ("%s%s?caid=%s " , baseUrl , accountSSLSettingsUrl , accountId )
180180 }
181181 return url
182182}
0 commit comments