ReferenceField to TagProvider in PersistentRecord

I'm trying to make a config on the gateway to have a tickbox to have a boolean config field per tag provider in a gateway. Essentially I'm trying to create a table with a one-to-one relationship to tag providers and an additional column for configuration.

Following this post, right now the PersistentRecord looks like:

public class TagProvidersConfigRecord extends PersistentRecord {
    ...
    // Reference to tag provider
    public static final LongField TagProviderId = new LongField(META, "TagProviderId", SFieldFlags.SPRIMARY_KEY);
    public static final ReferenceField<TagProviderSettingsRecord> TagProvider = new ReferenceField<>(META,
            TagProviderSettingsRecord.META, "Tag Provider", TagProviderId);
    ...
}

I think that's all fine, but I can't seem to find any APIs for getting an Id to reference the tag provider.

The closest thing I've found in the javadocs is the PROVIDER_ID property on TagProviderSettingsRecord (inductiveautomation.com) (hence the type in ReferenceField above). This seems like what I need but I can't find a way to get this from the gateway context? I can get the list of tag providers in the gateway setup with List<TagProvider> tagProviders = gatewayContext.getTagManager().getTagProviders(); but I can't find a way to get to the record from there.

If there's a better way to do this, please let me know as well.
Thank you in advance.

I'm not quite sure I understand the question, but BaseExtensionPointType (the abstract class at the root of the "extension point" mechanism we use to provide pluggable functionality like alarm journal types, tag provider types, etc) contains this protected implementation, to return the 'base' record given a reference field:

    /**
     * Convenience function for looking up the extension point's settings for the given profile. Relies on
     * getSettingsRecordForeignKey() to get the reference field for the settings record.
     */
    protected <T> T findProfileSettingsRecord(GatewayContext context, PersistentRecord profile) {
        if (getSettingsRecordType() == null || getSettingsRecordForeignKey() == null) {
            return null;
        }
        PersistenceSession session = context.getPersistenceInterface().getSession(profile.getDataSet());

        try {
            @SuppressWarnings("rawtypes")
            T result = (T) session.queryOne(
                new SQuery(getSettingsRecordType()).eq(getSettingsRecordForeignKey(), profile));

            return result;
        } finally {
            session.commitAndDetachDataSet();
            session.close();
        }
    }