import { logger } from "../../../common/logger.js";
import { printDiagnosticsToConsole, printResultToConsoleAndExitGracefully, textOrJson, } from "../../../common/output.js";
import settings from "../../../common/settings.js";
export async function describe(argv) {
    const { account } = argv;
    const describeResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/tunnels/${argv["tunnel-id"]}/services-configuration`, {
        method: "GET",
        headers: {
            Authorization: `Bearer ${argv.authToken}`,
        },
    });
    if (describeResponse.ok) {
        const tunnel = await describeResponse.json();
        await printResultToConsoleAndExitGracefully(JSON.stringify(tunnel, null, 2));
    }
    else {
        const response = textOrJson(await describeResponse.text());
        logger.error({
            status: describeResponse.status,
            statusText: describeResponse.statusText,
            response,
        }, "Failed to describe services for tunnel");
        printDiagnosticsToConsole("Error: Failed to describe the services for your tunnel. Check the arguments.", response);
    }
}
//# sourceMappingURL=handler.js.map