Skip to content

Commit c457efb

Browse files
committed
fix debug prints for policy asset association
1 parent e66ee4b commit c457efb

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

incapsula/client_policy_asset_association.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type PolicyAssetAssociationStatus struct {
1515

1616
// AddPolicyAssetAssociation adds a policy to be managed by Incapsula
1717
func (c *Client) AddPolicyAssetAssociation(policyID, assetID, assetType string) error {
18-
log.Printf("[INFO] Adding Incapsula Policy Asset Association: %s-%s-%s\n", policyID, assetID, assetType)
18+
log.Printf("[INFO] Adding Incapsula Policy Asset Association: %s/%s/%s\n", policyID, assetID, assetType)
1919

2020
// Post form to Incapsula
2121
reqURL := fmt.Sprintf("%s/policies/v2/assets/%s/%s/policies/%s", c.config.BaseURLAPI, assetType, assetID, policyID)
@@ -41,7 +41,7 @@ func (c *Client) AddPolicyAssetAssociation(policyID, assetID, assetType string)
4141

4242
// DeletePolicyAssetAssociation deletes a policy asset association currently managed by Incapsula
4343
func (c *Client) DeletePolicyAssetAssociation(policyID, assetID, assetType string) error {
44-
log.Printf("[INFO] Deleting Incapsula Policy Asset Association: %s-%s-%s\n", policyID, assetID, assetType)
44+
log.Printf("[INFO] Deleting Incapsula Policy Asset Association: %s/%s/%s\n", policyID, assetID, assetType)
4545

4646
// Delete request to Incapsula
4747
reqURL := fmt.Sprintf("%s/policies/v2/assets/%s/%s/policies/%s", c.config.BaseURLAPI, assetType, assetID, policyID)
@@ -66,32 +66,32 @@ func (c *Client) DeletePolicyAssetAssociation(policyID, assetID, assetType strin
6666
}
6767

6868
func (c *Client) isPolicyAssetAssociated(policyID, assetID, assetType string) (bool, error) {
69-
log.Printf("[INFO] Checking Policy Asset Association: %s-%s-%s\n", policyID, assetID, assetType)
69+
log.Printf("[INFO] Checking Policy Asset Association: %s/%s/%s\n", policyID, assetID, assetType)
7070

7171
// Check with Policies if the association exist
7272
reqURL := fmt.Sprintf("%s/policies/v2/policies/%s/assets/%s/%s", c.config.BaseURLAPI, policyID, assetType, assetID)
7373
resp, err := c.DoJsonRequestWithHeaders(http.MethodGet, reqURL, nil)
7474
if err != nil {
75-
return false, fmt.Errorf("error from Incapsula service when checking if Policy Asset Association exist: %s-%s-%s, err: %s", policyID, assetID, assetType, err)
75+
return false, fmt.Errorf("error from Incapsula service when checking if Policy Asset Association exist: %s/%s/%s, err: %s", policyID, assetID, assetType, err)
7676
}
7777

7878
// Read the body
7979
defer resp.Body.Close()
8080
responseBody, err := ioutil.ReadAll(resp.Body)
8181

82-
log.Printf("[DEBUG] Incapsula isPolicyAssetAssociated for: %s-%s-%s , response is: %s\n", policyID, assetID, assetType, string(responseBody))
82+
log.Printf("[DEBUG] Incapsula isPolicyAssetAssociated for: %s/%s/%s , response is: %s\n", policyID, assetID, assetType, string(responseBody))
8383

8484
// Check the response code
8585
// If policy asset is not associated 404 will be returned from policies
8686
if resp.StatusCode != 200 {
87-
return false, fmt.Errorf("Error status code %d from Incapsula service when checking the reading Policy Asset Association: %s-%s-%s, response is: %s", resp.StatusCode, policyID, assetID, assetType, string(responseBody))
87+
return false, fmt.Errorf("Error status code %d from Incapsula service when checking the reading Policy Asset Association: %s/%s/%s, response is: %s", resp.StatusCode, policyID, assetID, assetType, string(responseBody))
8888
}
8989

9090
// Parse the JSON
9191
var policyAssetAssociationStatus PolicyAssetAssociationStatus
9292
err = json.Unmarshal([]byte(responseBody), &policyAssetAssociationStatus)
9393
if err != nil {
94-
return false, fmt.Errorf("error parsing Policy Asset Association JSON response for Policy Asset Association: %d-%s-%s: %s\nresponse: %s, err: %s", resp.StatusCode, policyID, assetID, assetType, err, string(responseBody))
94+
return false, fmt.Errorf("error parsing Policy Asset Association JSON response for Policy Asset Association: %d/%s/%s: %s\nresponse: %s, err: %s", resp.StatusCode, policyID, assetID, assetType, err, string(responseBody))
9595
}
9696

9797
return true, nil

0 commit comments

Comments
 (0)