package models

import (
	"bwallet/pkg/rbac"
)

func AddPolicy(params [][]string) error {
	_, err := rbac.Ef.AddPolicies(params)
	if err != nil {
		return err
	}
	return nil
}

func AddGroupingPolicy(params map[string]interface{}) error {
	_, err := rbac.Ef.AddGroupingPolicy(params["v0"], params["v1"])
	if err != nil {
		return err
	}

	return nil
}

func RemoveGroupingPolicy(ptype string, fieldIndex int, fieldValues string) bool {
	success, _ := rbac.Ef.RemoveFilteredNamedGroupingPolicy(ptype, fieldIndex, fieldValues)
	return success
}

func RemovePolicy(ptype string, fieldIndex int, fieldValues string) bool {
	success, _ := rbac.Ef.RemoveFilteredNamedPolicy(ptype, fieldIndex, fieldValues)
	return success
}

func GetPolicies(ptype string, fieldIndex int, fieldValues string) [][]string {
	return rbac.Ef.GetFilteredNamedPolicy(ptype, fieldIndex, fieldValues)
}
