#!/usr/bin/env python3
from __future__ import annotations

from _common import API_ROOT, api_request, build_auth_parser, dump, tenant_access_token


def main() -> int:
    parser = build_auth_parser("Get Feishu spreadsheet metadata")
    parser.add_argument("--spreadsheet-token", required=True)
    args = parser.parse_args()
    token = tenant_access_token(args.app_id, args.app_secret)
    payload = api_request(
        "GET",
        f"{API_ROOT}/sheets/v2/spreadsheets/{args.spreadsheet_token}/metainfo",
        token=token,
    )
    dump(payload)
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
