Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The following values can either be added to the `config.yaml` file or entered wh
- PlexTrac Top Level Domain e.g. https://yourapp.plextrac.com
- Username
- Password
- Client ID (optional): used by the example `get_client` call; if omitted, the script uses the first client you have access to

## Script Execution Flow
- Starts executing the main.py file
Expand Down
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
instance_url:
username:
password:
# client_id: optional - used by example script; if omitted, first accessible client is used
22 changes: 20 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,26 @@ def main():
"""
import api

client_id = "<id_of_client>"
response = api.clients.get_client(auth.base_url, auth.get_auth_headers(), client_id)
# Get a real client ID: from config, or list clients first to pick one
client_id = args.get('client_id')
if not client_id:
clients_response = api.clients.list_tenant_clients(auth.base_url, auth.get_auth_headers(), auth.tenant_id)
if clients_response and 200 <= clients_response.status_code < 300:
clients = clients_response.json
# Response shape varies; extract first client id (e.g. from doc_id or data)
if isinstance(clients, list) and clients:
first = clients[0]
client_id = first.get('doc_id', [first.get('id')])[0] if isinstance(first, dict) else first
elif isinstance(clients, dict) and clients.get('data'):
client_id = clients['data'][0].get('doc_id', [clients['data'][0].get('id')])[0]
else:
client_id = None
else:
client_id = None
if not client_id:
log.warning("No clients found. Add client_id to config.yaml or ensure your user has access to clients.")
if client_id:
response = api.clients.get_client(auth.base_url, auth.get_auth_headers(), client_id)


"""
Expand Down