{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def read_and_dedupe(file_path):\n",
    "    with open(file_path, 'r') as file:\n",
    "        strings = file.readlines()\n",
    "    strings = [s.strip() for s in strings]\n",
    "    unique_strings = list(set(strings))\n",
    "    return unique_strings\n",
    "file_path = 'unprocessedAccountIds.csv'\n",
    "deduped_list = read_and_dedupe(file_path)\n",
    "for item in deduped_list:\n",
    "    print(item)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from api import BigApi\n",
    "BigApi.init(\".admin.env\")\n",
    "BigApi.adminLogin()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def fixScanRequests(unprocessedAccountId):\n",
    "    scanRequests = BigApi.adminGet(f\"/admin/fabricator/account/{unprocessedAccountId}/scan_requests\")\n",
    "    for scanRequest in scanRequests[\"items\"]:\n",
    "        if (scanRequest[\"scanRequestState\"] == \"AwaitingCustomerScan\"):\n",
    "            scanRequestId = scanRequest['id']\n",
    "            print(f\"Fixing scan request {scanRequestId} for account {unprocessedAccountId}\")\n",
    "            d1 = BigApi.adminGet(f\"/admin/fabricator/scan_request/{scanRequestId}/topology\")\n",
    "            d2 = BigApi.adminGet(f\"/admin/fabricator/scan_request/{scanRequestId}/verify\")\n",
    "            print(d1, d2)\n",
    "            break\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for item in deduped_list:\n",
    "    # strip \"https://main-ocean-arda.bigscreencloud.com/account/\" from the beginning of the string\n",
    "    accountId = item[51:]\n",
    "    fixScanRequests(accountId)\n",
    "    "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
