export function getEventTypeFromTopic()

in src/eventSubscription/commands/mock/createMockEventGenerator.ts [119:142]


export function getEventTypeFromTopic(topic: string): EventType {
    if (/^\/subscriptions\/[^\/]+$/i.test(topic) || /^\/subscriptions\/.*\/resourceGroups\/[^\/]+$/i.test(topic)) {
        return EventType.Resources;
    } else {
        const result: RegExpExecArray | null = /^\/subscriptions\/.*\/resourceGroups\/.*\/providers\/(.*)\/[^\/]+$/i.exec(topic);
        if (result && result.length > 1) {
            switch (result[1].toLowerCase()) {
                case 'microsoft.storage/storageaccounts':
                    return EventType.Storage;
                case 'microsoft.containerregistry/registries':
                    return EventType.ContainerRegistry;
                case 'microsoft.devices/iothubs':
                    return EventType.Devices;
                case 'microsoft.eventhub/namespaces':
                    return EventType.EventHub;
                case 'microsoft.eventgrid/topics':
                    return EventType.Custom;
                default:
            }
        }

        throw new Error(localize('unsupportedType', 'The topic type for this Event Subscription is not yet supported.'));
    }
}