async function getEndpointUrl()

in src/eventSubscription/commands/mock/sendEvents.ts [55:76]


async function getEndpointUrl(eventGenerator: IMockEventGenerator): Promise<string> {
    if (eventGenerator.destination) {
        if (eventGenerator.destination.endpointUrl) {
            return eventGenerator.destination.endpointUrl;
        } else if (eventGenerator.destination.eventSubscriptionId) {
            const node: EventSubscriptionTreeItem | undefined = <EventSubscriptionTreeItem | undefined>await ext.eventSubscriptionTree.findTreeItem(eventGenerator.destination.eventSubscriptionId);
            if (node) {
                const client: EventGridManagementClient = createAzureClient(node.root, EventGridManagementClient);
                const url: EventSubscriptionFullUrl = await client.eventSubscriptions.getFullUrl(node.topic, node.name);
                if (url.endpointUrl) {
                    return url.endpointUrl;
                } else {
                    throw new Error(localize('failedToGetUrl', 'Failed to retrieve endpoint URL.'));
                }
            } else {
                throw new Error(localize('failedToFindNode', 'Failed to find Event Grid Subscription with id "{0}".', eventGenerator.destination.eventSubscriptionId));
            }
        }
    }

    throw new Error(localize('destinationRequired', 'You must specify either an "endpointUrl" or "eventSubscriptionId" as the destination.'));
}