/*!
 * Copyright (C) Microsoft Corporation. All rights reserved.
 */
import { getConnectionByNameAsync, getConnectorAsync, getDatasetsAsync } from '../services/index.js';
export async function listDatasetsAsync(context) {
    const connectorName = context.actionsParams.apiId;
    const connectionName = context.actionsParams.connectionId;
    if (!connectorName || !connectionName) {
        throw new Error('Both Argument apiId and Argument connectionId are required to list datasets. Use --apiId or -a and --connectionId or -c to specify them.');
    }
    const connector = await getConnectorAsync(connectorName);
    if (!connector) {
        throw new Error(`Connector with name ${connectorName} not found.`);
    }
    const connection = await getConnectionByNameAsync(connectionName, connectorName);
    if (!connection) {
        throw new Error(`Connection with name ${connectionName} not found for connector ${connectorName}.`);
    }
    return await getDatasetsAsync(connection, connector, context.logger);
}
//# sourceMappingURL=ListDatasets.js.map