forked from Olog/phoebus-pyolog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_template.py
More file actions
58 lines (49 loc) · 1.77 KB
/
debug_template.py
File metadata and controls
58 lines (49 loc) · 1.77 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
#!/usr/bin/env python3
import os
import json
import sys
sys.path.append('src')
from pyolog import OlogClient
def debug_template_creation():
# Setup client
username = os.getenv("OLOG_USERNAME")
password = os.getenv("OLOG_PASSWORD")
if not username or not password:
print("Error: OLOG_USERNAME and OLOG_PASSWORD environment variables must be set")
return
client = OlogClient(base_url="http://localhost:8080", client_info="Debug Template Test")
client.set_auth(username, password)
# First, let's get existing templates to see the structure
print("=== Existing Templates ===")
try:
templates = client.get_templates()
for template in templates:
print(f"Template: {json.dumps(template, indent=2)}")
print("-" * 50)
except Exception as e:
print(f"Error getting templates: {e}")
# Now try to create a minimal template
print("\n=== Creating New Template ===")
try:
template_data = {
"name": "debug-test-template",
"title": "Debug Test Template",
"logbooks": [{"name": "operations"}],
"tags": [],
"properties": []
}
print(f"Sending template data: {json.dumps(template_data, indent=2)}")
# Try the creation
result = client.create_template(
name="debug-test-template",
title="Debug Test Template",
logbooks=["operations"],
tags=[],
properties=[]
)
print(f"Success! Created template: {json.dumps(result, indent=2)}")
except Exception as e:
print(f"Error creating template: {e}")
print(f"Error type: {type(e)}")
if __name__ == "__main__":
debug_template_creation()