-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_usage.py
More file actions
65 lines (55 loc) · 2.05 KB
/
Copy pathbasic_usage.py
File metadata and controls
65 lines (55 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
Basic usage example — login, create operation, ingest, query.
"""
import asyncio
from gulp_sdk import GulpClient, AuthenticationError
async def main():
"""Run basic workflow example."""
# Connect to Gulp server
async with GulpClient("http://localhost:8080") as client:
# 1. Authenticate
print("Logging in...")
try:
session = await client.auth.login("admin", "admin")
print(f"✓ Logged in: {session.user_id}")
except AuthenticationError as e:
print(f"✗ Login failed: {e.message}")
return
# 2. Create operation
print("\nCreating operation...")
op = await client.operations.create(
name="Example Investigation",
description="Demonstration of SDK usage",
)
print(f"✓ Created operation: {op.id} — {op.name}")
# 3. Get current user info
print("\nGetting current user...")
user = await client.users.get_current()
print(f"✓ Current user: {user.display_name or user.username}")
# 4. List operations
print("\nListing operations...")
count = 0
async for operation in client.operations.list(limit=10):
count += 1
print(f" - {operation.name} ({operation.id})")
if count >= 3:
break
# 5. Add a note (collaboration)
print("\nAdding collaboration note...")
if op.id:
# Create a dummy document first (in real usage)
try:
note = await client.collab.create_note(
op.id,
"doc-123",
"This is an important finding!",
)
print(f"✓ Created note: {note.id}")
except Exception as e:
print(f"✓ Note creation demo (expected to fail in example): {type(e).__name__}")
# 6. Logout
print("\nLogging out...")
await client.auth.logout()
print("✓ Logged out")
if __name__ == "__main__":
asyncio.run(main())