Hi Team, func ListPolicies() { list, err := admcl...
# help
a
Hi Team, func ListPolicies() { list, err := admcli.ListPolicies(context.Background()) if err != nil { fmt.Printf("error getting lists: %v", err) } for _, v := range list { fmt.Printf(" %s \n", v) } } policy ID necessary for disabling a policy, could you please provide more context about how we get the policy ID?
d
The
ListPolicies
method returns a slice of policy IDs, which can be used, for example, to disable a policy. Here’s a fragment of a test:
Copy code
have, err := ac.ListPolicies(ctx, WithIncludeDisabled())
		require.NoError(t, err)
		require.NotEmpty(t, have)

		id := have[0]
		p, err := ac.GetPolicy(ctx, id)
		require.NoError(t, err)
		require.Len(t, p, 1)
		require.False(t, p[0].Disabled)

		n, err := ac.DisablePolicy(ctx, id)
		require.NoError(t, err)
		require.Equal(t, uint32(1), n)

		p, err = ac.GetPolicy(ctx, id)
		require.NoError(t, err)
		require.Len(t, p, 1)
		require.True(t, p[0].Disabled)
a
@Dennis (Cerbos) i have tried with ListPolicies method but it only give slice of policy name, not policy ID.
Do we have any other method to get the policy ID?
d
These policy names are effectively policy IDs, which can be used to disable policies as per my example. Sorry if I am missing your point. What do you want to do with the policy ID?