Skip to content

Commit c9228eb

Browse files
committed
Add function for listing targets
1 parent 719c1d6 commit c9228eb

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/vws/vws.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import io
77
import json
88
from time import sleep
9-
from typing import Any, Dict, Union
9+
from typing import Any, Dict, List, Union
1010
from urllib.parse import urljoin
1111

1212
import requests
@@ -179,3 +179,21 @@ def wait_for_target_processed(self, target_id: str) -> None:
179179
# number of calls made to the API, to decrease the likelihood of
180180
# hitting the request quota.
181181
sleep(0.2)
182+
183+
def list_targets(self) -> List[str]:
184+
"""
185+
Get a list of targets.
186+
187+
Returns:
188+
The IDs of all targets in the database.
189+
"""
190+
response = _target_api_request(
191+
server_access_key=self._server_access_key,
192+
server_secret_key=self._server_secret_key,
193+
method='GET',
194+
content=b'',
195+
request_path='/targets',
196+
base_vws_url=self._base_vws_url,
197+
)
198+
199+
return list(response.json()['results'])

0 commit comments

Comments
 (0)