func DeletePolicy(ctx context.Context, clientsEndpoint string, clientID string, policyID string, protectionAPIToken string) error {
	req, err := http.NewRequest("DELETE", clientsEndpoint+"/"+clientID+"/authz/resource-server/policy/"+policyID, nil)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err.Error(),
		}, "Unable to crete http request")
		return errors.NewInternalError("unable to crete http request " + err.Error())
	}
	req.Header.Add("Authorization", "Bearer "+protectionAPIToken)
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"policy_id": policyID,
			"err":       err.Error(),
		}, "Unable to delete the Keycloak policy")
		return errors.NewInternalError("Unable to delete the Keycloak policy " + err.Error())
	}
	if res.StatusCode != http.StatusNoContent {
		log.Error(ctx, map[string]interface{}{
			"policy_id":       policyID,
			"response_status": res.Status,
			"response_body":   rest.ReadBody(res.Body),
		}, "Unable to delete the Keycloak policy")
		return errors.NewInternalError("Unable to delete the Keycloak policy. Response status: " + res.Status + ". Responce body: " + rest.ReadBody(res.Body))
	}

	log.Debug(ctx, map[string]interface{}{
		"policy_id": policyID,
	}, "Keycloak policy deleted")

	return nil
}
// DeletePolicy deletes the Keycloak policy
DeletePolicy deletes the Keycloak policy
// DeletePolicy deletes the Keycloak policy
func DeletePolicy(ctx context.Context, clientsEndpoint string, clientID string, policyID string, protectionAPIToken string) error {
	req, err := http.NewRequest("DELETE", clientsEndpoint+"/"+clientID+"/authz/resource-server/policy/"+policyID, nil)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err.Error(),
		}, "Unable to crete http request")
		return errors.NewInternalError("unable to crete http request " + err.Error())
	}
	req.Header.Add("Authorization", "Bearer "+protectionAPIToken)
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"policy_id": policyID,
			"err":       err.Error(),
		}, "Unable to delete the Keycloak policy")
		return errors.NewInternalError("Unable to delete the Keycloak policy " + err.Error())
	}
	if res.StatusCode != http.StatusNoContent {
		log.Error(ctx, map[string]interface{}{
			"policy_id":       policyID,
			"response_status": res.Status,
			"response_body":   rest.ReadBody(res.Body),
		}, "Unable to delete the Keycloak policy")
		return errors.NewInternalError("Unable to delete the Keycloak policy. Response status: " + res.Status + ". Responce body: " + rest.ReadBody(res.Body))
	}
	log.Debug(ctx, map[string]interface{}{
		"policy_id": policyID,
	}, "Keycloak policy deleted")
	return nil
}
func DeletePolicy ( ctx context . Context , clientsEndpoint string , clientID string , policyID string , protectionAPIToken string ) error { req , err := http . NewRequest ( " " , clientsEndpoint + " " + clientID + " " + policyID , nil ) if err != nil { log . Error ( ctx , map [ string ] interface { } { " " : err . Error ( ) , } , " " ) return errors . NewInternalError ( " " + err . Error ( ) ) } req . Header . Add ( " " , " " + protectionAPIToken ) res , err := http . DefaultClient . Do ( req ) if err != nil { log . Error ( ctx , map [ string ] interface { } { " " : policyID , " " : err . Error ( ) , } , " " ) return errors . NewInternalError ( " " + err . Error ( ) ) } if res . StatusCode != http . StatusNoContent { log . Error ( ctx , map [ string ] interface { } { " " : policyID , " " : res . Status , " " : rest . ReadBody ( res . Body ) , } , " " ) return errors . NewInternalError ( " " + res . Status + " " + rest . ReadBody ( res . Body ) ) } log . Debug ( ctx , map [ string ] interface { } { " " : policyID , } , " " ) return nil }
DeletePolicy deletes the Keycloak policy
DeletePolicy deletes the Keycloak policy