public static ApiVersionCollection filterApis(
        RecordVersion minRecordVersion,
        ApiMessageType.ListenerType listenerType,
        boolean enableUnstableLastVersion,
        boolean clientTelemetryEnabled
    ) {
        ApiVersionCollection apiKeys = new ApiVersionCollection();
        for (ApiKeys apiKey : ApiKeys.apisForListener(listenerType)) {
            // Skip telemetry APIs if client telemetry is disabled.
            if ((apiKey == ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS || apiKey == ApiKeys.PUSH_TELEMETRY) && !clientTelemetryEnabled)
                continue;

            if (apiKey.minRequiredInterBrokerMagic <= minRecordVersion.value) {
                apiKey.toApiVersion(enableUnstableLastVersion).ifPresent(apiKeys::add);
            }
        }
        return apiKeys;
    }
Possible error codes:
- {@link Errors#UNSUPPORTED_VERSION}
- {@link Errors#INVALID_REQUEST}
clients/src/main/java/org/apache/kafka/common/requests/ApiVersionsResponse.java