Skip to content

Commit f57ed2a

Browse files
committed
Adjust script
1 parent 713889b commit f57ed2a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

backend/scripts/resume_paused_connectors.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44

55
API_SERVER_URL = "http://localhost:3000"
66
API_KEY = "onyx-api-key" # API key here, if auth is enabled
7-
HEADERS = {"Content-Type": "application/json", "Authorization": f"Bearer {API_KEY}"}
87

98

109
def resume_paused_connectors(
1110
api_server_url: str,
11+
api_key: str | None,
1212
specific_connector_sources: list[str] | None = None,
1313
) -> None:
14+
headers = {"Content-Type": "application/json"}
15+
if api_key:
16+
headers["Authorization"] = f"Bearer {api_key}"
17+
1418
# Get all paused connectors
1519
response = requests.get(
1620
f"{api_server_url}/api/manage/admin/connector/indexing-status",
17-
headers=HEADERS,
21+
headers=headers,
1822
)
1923
response.raise_for_status()
2024

@@ -35,7 +39,7 @@ def resume_paused_connectors(
3539
response = requests.put(
3640
f"{api_server_url}/api/manage/admin/cc-pair/{connector['cc_pair_id']}/status",
3741
json={"status": "ACTIVE"},
38-
headers=HEADERS,
42+
headers=headers,
3943
)
4044
response.raise_for_status()
4145
print(f"Resumed connector: {connector['name']}")
@@ -52,6 +56,12 @@ def main() -> None:
5256
default=API_SERVER_URL,
5357
help="The URL of the API server to use. If not provided, will use the default.",
5458
)
59+
parser.add_argument(
60+
"--api_key",
61+
type=str,
62+
default=None,
63+
help="The API key to use for authentication. If not provided, no authentication will be used.",
64+
)
5565
parser.add_argument(
5666
"--connector_sources",
5767
type=str.lower,
@@ -60,7 +70,7 @@ def main() -> None:
6070
)
6171
args = parser.parse_args()
6272

63-
resume_paused_connectors(args.api_server_url, args.connector_sources)
73+
resume_paused_connectors(args.api_server_url, args.api_key, args.connector_sources)
6474

6575

6676
if __name__ == "__main__":

0 commit comments

Comments
 (0)