Validation-set refresh not supported on snapd REST API (2.63)?

Is it correct that something like

snap validate --enforce --refresh ...

Is not supported on snapd 2.63?

I have briefly investigated the code and it seems like the --refresh option is “acted on” before the API call to the snapd client.

See code snippet here
func (cmd *cmdValidate) Execute(args []string) error {
	// check that only one action is used at a time
	var action string
	for _, a := range []struct {
		name string
		set  bool
	}{
		{"monitor", cmd.Monitor},
		{"enforce", cmd.Enforce},
		{"forget", cmd.Forget},
	} {
		if a.set {
			if action != "" {
				return fmt.Errorf("cannot use --%s and --%s together", action, a.name)
			}
			action = a.name
		}
	}

	if cmd.Positional.ValidationSet == "" && action != "" {
		return fmt.Errorf("missing validation set argument")
	}

	var accountID, name string
	var seq int
	var err error
	if cmd.Positional.ValidationSet != "" {
		accountID, name, seq, err = snapasserts.ParseValidationSet(cmd.Positional.ValidationSet)
		if err != nil {
			return err
		}
	}

	if action != "" {
		if cmd.Refresh && action != "enforce" {
			return fmt.Errorf("--refresh can only be used together with --enforce")
		}

		if cmd.Refresh {
			changeID, err := cmd.client.RefreshMany(nil, &client.SnapOptions{
				ValidationSets: []string{cmd.Positional.ValidationSet},
			})
			if err != nil {
				return err
			}
			chg, err := cmd.wait(changeID)
			if err != nil {
				if err == noWait {
					return nil
				}
				return err
			}

			var names []string
			if err := chg.Get("snap-names", &names); err != nil && !errors.Is(err, client.ErrNoData) {
				return err
			}

			if len(names) != 0 {
				fmt.Fprintf(Stdout, i18n.G("Refreshed/installed snaps %s to enforce validation set %q\n"), strutil.Quoted(names), cmd.Positional.ValidationSet)
			} else {
				fmt.Fprintf(Stdout, i18n.G("Enforced validation set %q\n"), cmd.Positional.ValidationSet)
			}

			return nil
		}

		// forget
		if cmd.Forget {
			return cmd.client.ForgetValidationSet(accountID, name, seq)
		}
		// apply
		opts := &client.ValidateApplyOptions{
			Mode:     action,
			Sequence: seq,
		}
		res, err := cmd.client.ApplyValidationSet(accountID, name, opts)
...

Is there a reason not to do this on the “other” side? That is, add the option to the REST API and doing the refresh on the snapd server side?

I understand I can probably implement the refresh in a similar way as is done in the snapd application, but double implementation is not ideal.

Regards, Charlee

Found out that the endpoint I was using was not correct. The correct way to do snap validate --refresh --enforce is:

# ... Some code to setup snapd socket and variables ...

print("Triggering validation set update")
headers = {
    "Content-Type": "application/json"
}
payload = {
    "action" : "refresh",
    "mode" : "enforce",
    "validation-sets" : [f"{validationset_accountid}/{validationset_name}={validationset_sequence}"],
}
url = f"{base_url}snaps"

print(f"Doing request to {url} with payload {payload}")
response = session.post(url, headers=headers, json=payload).json()