Check via iRule if data group exists

Hello All,

I am new to iRules, hope you can help me out. Thank you in advance.

The use case is that I want to double-check on a specific data group availability, hence to check whether it exists or not. AFAIK the data group from iRule point of view is called classes, and I am aware about the catch command as well, so was wondering about something like the following, just not sure what command(s) to use in place of ???:

if {[catch {class ??? my_data_group_name}]} {

# The class does not exist

} else {

# The class exists

}

if { [class exists my_data_group_name] } {
    # do something
}

Many thanks JG!