4
4
5
5
API_SERVER_URL = "http://localhost:3000"
6
6
API_KEY = "onyx-api-key" # API key here, if auth is enabled
7
- HEADERS = {"Content-Type" : "application/json" , "Authorization" : f"Bearer { API_KEY } " }
8
7
9
8
10
9
def resume_paused_connectors (
11
10
api_server_url : str ,
11
+ api_key : str | None ,
12
12
specific_connector_sources : list [str ] | None = None ,
13
13
) -> None :
14
+ headers = {"Content-Type" : "application/json" }
15
+ if api_key :
16
+ headers ["Authorization" ] = f"Bearer { api_key } "
17
+
14
18
# Get all paused connectors
15
19
response = requests .get (
16
20
f"{ api_server_url } /api/manage/admin/connector/indexing-status" ,
17
- headers = HEADERS ,
21
+ headers = headers ,
18
22
)
19
23
response .raise_for_status ()
20
24
@@ -35,7 +39,7 @@ def resume_paused_connectors(
35
39
response = requests .put (
36
40
f"{ api_server_url } /api/manage/admin/cc-pair/{ connector ['cc_pair_id' ]} /status" ,
37
41
json = {"status" : "ACTIVE" },
38
- headers = HEADERS ,
42
+ headers = headers ,
39
43
)
40
44
response .raise_for_status ()
41
45
print (f"Resumed connector: { connector ['name' ]} " )
@@ -52,6 +56,12 @@ def main() -> None:
52
56
default = API_SERVER_URL ,
53
57
help = "The URL of the API server to use. If not provided, will use the default." ,
54
58
)
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
+ )
55
65
parser .add_argument (
56
66
"--connector_sources" ,
57
67
type = str .lower ,
@@ -60,7 +70,7 @@ def main() -> None:
60
70
)
61
71
args = parser .parse_args ()
62
72
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 )
64
74
65
75
66
76
if __name__ == "__main__" :
0 commit comments