mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-25 09:01:29 +02:00
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package networkmap_sqlite
|
|
|
|
import (
|
|
"context"
|
|
|
|
networkmapdb "github.com/netbirdio/netbird/management/internals/network_map_db"
|
|
"github.com/netbirdio/netbird/shared/management/networkmap/nmdata"
|
|
)
|
|
|
|
const (
|
|
GetPoliciesQuery = `
|
|
select p.id, p.public_id, p.enabled, p.source_posture_checks, pr.enabled as rule_enabled, pr.action, pr.protocol, pr.bidirectional,
|
|
pr.sources, pr.destinations, pr.source_resource, pr.destination_resource, pr.ports, pr.port_ranges,
|
|
pr.authorized_groups, pr.authorized_user
|
|
from policies as p
|
|
left join policy_rules as pr on p.id = pr.policy_id
|
|
where account_id=?
|
|
`
|
|
)
|
|
|
|
func (sc *SqliteStoreConn) GetPolicies(ctx context.Context, accountId string) ([]nmdata.Policy, map[string]map[string]any, map[string]map[string]any, error) {
|
|
rows, err := sc.Conn.QueryContext(ctx, GetPoliciesQuery, accountId)
|
|
if err != nil {
|
|
return nil, nil, nil, err
|
|
}
|
|
|
|
policies, err := CollectRowsForSqlite[networkmapdb.Policy](rows)
|
|
if err != nil {
|
|
return nil, nil, nil, err
|
|
}
|
|
|
|
return networkmapdb.ConvertToNmdataPolicy(policies)
|
|
}
|