This MVP release provides a complete full-stack solution for managing action mappings in Geutebruck's GeViScope and GeViSoft video surveillance systems. ## Features ### Flutter Web Application (Port 8081) - Modern, responsive UI for managing action mappings - Action picker dialog with full parameter configuration - Support for both GSC (GeViScope) and G-Core server actions - Consistent UI for input and output actions with edit/delete capabilities - Real-time action mapping creation, editing, and deletion - Server categorization (GSC: prefix for GeViScope, G-Core: prefix for G-Core servers) ### FastAPI REST Backend (Port 8000) - RESTful API for action mapping CRUD operations - Action template service with comprehensive action catalog (247 actions) - Server management (G-Core and GeViScope servers) - Configuration tree reading and writing - JWT authentication with role-based access control - PostgreSQL database integration ### C# SDK Bridge (gRPC, Port 50051) - Native integration with GeViSoft SDK (GeViProcAPINET_4_0.dll) - Action mapping creation with correct binary format - Support for GSC and G-Core action types - Proper Camera parameter inclusion in action strings (fixes CrossSwitch bug) - Action ID lookup table with server-specific action IDs - Configuration reading/writing via SetupClient ## Bug Fixes - **CrossSwitch Bug**: GSC and G-Core actions now correctly display camera/PTZ head parameters in GeViSet - Action strings now include Camera parameter: `@ PanLeft (Comment: "", Camera: 101028)` - Proper filter flags and VideoInput=0 for action mappings - Correct action ID assignment (4198 for GSC, 9294 for G-Core PanLeft) ## Technical Stack - **Frontend**: Flutter Web, Dart, Dio HTTP client - **Backend**: Python FastAPI, PostgreSQL, Redis - **SDK Bridge**: C# .NET 8.0, gRPC, GeViSoft SDK - **Authentication**: JWT tokens - **Configuration**: GeViSoft .set files (binary format) ## Credentials - GeViSoft/GeViScope: username=sysadmin, password=masterkey - Default admin: username=admin, password=admin123 ## Deployment All services run on localhost: - Flutter Web: http://localhost:8081 - FastAPI: http://localhost:8000 - SDK Bridge gRPC: localhost:50051 - GeViServer: localhost (default port) Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
169 lines
5.7 KiB
Python
169 lines
5.7 KiB
Python
import requests
|
|
import json
|
|
|
|
# Base URL
|
|
base_url = "http://localhost:8000"
|
|
|
|
print("=== Testing Action Mapping CRUD Operations ===\n")
|
|
|
|
# Step 1: Authenticate
|
|
print("Step 1: Authenticating...")
|
|
auth_url = f"{base_url}/api/v1/auth/login"
|
|
auth_payload = {
|
|
"username": "admin",
|
|
"password": "admin123"
|
|
}
|
|
|
|
try:
|
|
auth_response = requests.post(auth_url, json=auth_payload)
|
|
if auth_response.status_code != 200:
|
|
print(f"Auth failed: {auth_response.text}")
|
|
exit(1)
|
|
|
|
token = auth_response.json().get("access_token")
|
|
print(f"Successfully authenticated!\n")
|
|
|
|
headers = {
|
|
"Content-Type": "application/json",
|
|
"Authorization": f"Bearer {token}"
|
|
}
|
|
|
|
# Step 2: CREATE - Create a new action mapping
|
|
print("Step 2: CREATE - Creating new action mapping...")
|
|
create_url = f"{base_url}/api/v1/configuration/action-mappings"
|
|
create_payload = {
|
|
"name": "CRUD Test Mapping",
|
|
"output_actions": [
|
|
{
|
|
"action": "SendMail",
|
|
"parameters": {
|
|
"Server": "mail.example.com",
|
|
"To": "test@example.com"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
|
|
create_response = requests.post(create_url, json=create_payload, headers=headers)
|
|
print(f"CREATE Status: {create_response.status_code}")
|
|
|
|
if create_response.status_code == 201:
|
|
print("CREATE successful!")
|
|
create_data = create_response.json()
|
|
print(json.dumps(create_data, indent=2))
|
|
else:
|
|
print(f"CREATE failed: {create_response.text}")
|
|
exit(1)
|
|
|
|
# Step 3: READ - List all action mappings to find the ID
|
|
print("\nStep 3: READ - Reading all action mappings...")
|
|
read_url = f"{base_url}/api/v1/configuration/action-mappings/export"
|
|
read_response = requests.get(read_url, headers=headers)
|
|
|
|
if read_response.status_code == 200:
|
|
read_data = read_response.json()
|
|
print(f"Total mappings: {read_data.get('total_mappings', 0)}")
|
|
|
|
# Find our test mapping
|
|
test_mapping_id = None
|
|
for idx, mapping in enumerate(read_data.get("mappings", []), 1):
|
|
if mapping.get("name") == "CRUD Test Mapping":
|
|
test_mapping_id = idx
|
|
print(f"\nFound our test mapping at ID {test_mapping_id}:")
|
|
print(json.dumps(mapping, indent=2))
|
|
break
|
|
|
|
if not test_mapping_id:
|
|
print("ERROR: Could not find the created mapping!")
|
|
exit(1)
|
|
else:
|
|
print(f"READ failed: {read_response.text}")
|
|
exit(1)
|
|
|
|
# Step 4: UPDATE - Update the action mapping
|
|
print(f"\nStep 4: UPDATE - Updating action mapping ID {test_mapping_id}...")
|
|
update_url = f"{base_url}/api/v1/configuration/action-mappings/{test_mapping_id}"
|
|
update_payload = {
|
|
"name": "CRUD Test Mapping (Updated)",
|
|
"output_actions": [
|
|
{
|
|
"action": "SendMail",
|
|
"parameters": {
|
|
"Server": "mail.updated.com",
|
|
"To": "updated@example.com",
|
|
"Subject": "Updated Test"
|
|
}
|
|
},
|
|
{
|
|
"action": "StartEvent",
|
|
"parameters": {
|
|
"TypeID": "100",
|
|
"ForeignKey": "test-key"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
|
|
update_response = requests.put(update_url, json=update_payload, headers=headers)
|
|
print(f"UPDATE Status: {update_response.status_code}")
|
|
|
|
if update_response.status_code == 200:
|
|
print("UPDATE successful!")
|
|
update_data = update_response.json()
|
|
print(json.dumps(update_data, indent=2))
|
|
else:
|
|
print(f"UPDATE failed: {update_response.text}")
|
|
|
|
# Step 5: READ again to verify update
|
|
print("\nStep 5: READ - Verifying update...")
|
|
read_response2 = requests.get(read_url, headers=headers)
|
|
|
|
if read_response2.status_code == 200:
|
|
read_data2 = read_response2.json()
|
|
for idx, mapping in enumerate(read_data2.get("mappings", []), 1):
|
|
if idx == test_mapping_id:
|
|
print(f"Mapping ID {test_mapping_id} after update:")
|
|
print(json.dumps(mapping, indent=2))
|
|
|
|
if mapping.get("name") == "CRUD Test Mapping (Updated)":
|
|
print("\nUpdate verified successfully!")
|
|
else:
|
|
print("\nWARNING: Update may not have been applied")
|
|
break
|
|
|
|
# Step 6: DELETE - Delete the action mapping
|
|
print(f"\nStep 6: DELETE - Deleting action mapping ID {test_mapping_id}...")
|
|
delete_url = f"{base_url}/api/v1/configuration/action-mappings/{test_mapping_id}"
|
|
delete_response = requests.delete(delete_url, headers=headers)
|
|
print(f"DELETE Status: {delete_response.status_code}")
|
|
|
|
if delete_response.status_code == 204:
|
|
print("DELETE successful!")
|
|
else:
|
|
print(f"DELETE response: {delete_response.text}")
|
|
|
|
# Step 7: READ final to verify deletion
|
|
print("\nStep 7: READ - Verifying deletion...")
|
|
read_response3 = requests.get(read_url, headers=headers)
|
|
|
|
if read_response3.status_code == 200:
|
|
read_data3 = read_response3.json()
|
|
print(f"Total mappings after delete: {read_data3.get('total_mappings', 0)}")
|
|
|
|
found = False
|
|
for mapping in read_data3.get("mappings", []):
|
|
if mapping.get("name") in ["CRUD Test Mapping", "CRUD Test Mapping (Updated)"]:
|
|
found = True
|
|
print("\nWARNING: Test mapping still exists after deletion!")
|
|
break
|
|
|
|
if not found:
|
|
print("\nDeletion verified successfully!")
|
|
|
|
print("\n=== CRUD Test Complete ===")
|
|
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|