Multiple choice leaf statement

Hi,

I need to design a CLI command using YANG where the user can configure one or multiple SSH MAC algorithms. Also, they can remove one or more algorithms in the “no” form. However, none of the methods I have tried meet my requirements.

container mac-algorithm {
            choice mac-algo {
                description "Configure SSH MACs algorithms.";
                case algo {
                    leaf-list mac-algos {
                    leaf hmac-sha1 {
                        description "Configure hmac-sha1 algo";
                        type empty;
                    }
                    leaf hmac-sha2-256 {
                        description "Configure hmac-sha2-256 algo";
                        type empty;
                    }
                    leaf hmac-sha2-512 {
                        description "Configure hmac-sha2-512 algo";
                        type empty;
                    }
                    leaf "hmac-sha1-etm-openssh.com" {
                        description "Configure hmac-sha1-etm@openssh.com algo";
                        type empty;
                    }
                    leaf "hmac-sha2-256-etm-openssh.com" {
                        description "Configure hmac-sha2-256-etm@openssh.com algo";
                        type empty;
                    }
                    leaf "hmac-sha2-512-etm-openssh.com" {
                        description "Configure hmac-sha2-512-etm@openssh.com algo";
                        type empty;
                    }
                    }
                }
            }
        }

You could use simple list with a typedef enum for the algorithm types in which each element of the list represents an algorithm in use, e.g.:

  typedef mac-algo {
    type enumeration {
      enum hmac-sha1;
      enum hmac-sha2-256;
      enum hmac-sha2-512;
    }
  }
  list algorithms-in-use {
    key algo;

    leaf algo {
      type mac-algo;
    }
  }

You can add and delete entries to the list and the general list management ensures uniqueness.

% set algorithms-in-use hmac-sha2-512 
[ok][2024-08-03 17:01:01]

% show algorithms-in-use 
algorithms-in-use hmac-sha1;
algorithms-in-use hmac-sha2-512;

and with the ‘no’ command:

no algorithms-in-use hmac-sha1
commit

show running-config algorithms-in-use 
algorithms-in-use hmac-sha2-512
!