0
# System Operations & Administration
1
2
Administrative and system-level operations including server information, session management, backup, reindexing, and application configuration. These operations typically require system administrator permissions.
3
4
## Capabilities
5
6
### Server Information & Properties
7
8
Retrieve server configuration, version information, and manage application properties.
9
10
```python { .api }
11
def server_info(self) -> dict:
12
"""
13
Get JIRA server information including version, build, and deployment details.
14
15
Returns:
16
Dictionary containing server information
17
"""
18
19
def myself(self) -> User:
20
"""
21
Get current authenticated user information.
22
23
Returns:
24
User object for current user
25
"""
26
27
def current_user(self) -> str:
28
"""
29
Get current authenticated username.
30
31
Returns:
32
Username string
33
"""
34
35
def application_properties(self, key: str = None) -> dict:
36
"""
37
Get server application properties.
38
39
Parameters:
40
- key: Specific property key to retrieve (returns all if None)
41
42
Returns:
43
Dictionary of application properties
44
"""
45
46
def set_application_property(self, key: str, value: str) -> dict:
47
"""
48
Set an application property value.
49
50
Parameters:
51
- key: Property key
52
- value: Property value
53
54
Returns:
55
Response dictionary
56
"""
57
58
def applicationlinks(self, cached: bool = True) -> list[dict]:
59
"""
60
Get application links configured in JIRA.
61
62
Parameters:
63
- cached: Whether to use cached results
64
65
Returns:
66
List of application link dictionaries
67
"""
68
```
69
70
Usage examples:
71
```python
72
# Get server information
73
server_info = jira.server_info()
74
print(f"JIRA Version: {server_info['version']}")
75
print(f"Build Number: {server_info['buildNumber']}")
76
print(f"Server Time: {server_info['serverTime']}")
77
print(f"Deployment Type: {server_info['deploymentType']}")
78
79
# Get current user info
80
current_user = jira.myself()
81
print(f"Logged in as: {current_user.displayName}")
82
print(f"Email: {current_user.emailAddress}")
83
print(f"Time Zone: {current_user.timeZone}")
84
85
# Get username only
86
username = jira.current_user()
87
print(f"Current username: {username}")
88
89
# Get application properties
90
all_props = jira.application_properties()
91
for key, value in all_props.items():
92
print(f"{key}: {value}")
93
94
# Get specific property
95
jira_title = jira.application_properties('jira.title')
96
print(f"JIRA Instance Title: {jira_title}")
97
98
# Set application property (requires admin permissions)
99
jira.set_application_property('jira.title', 'My Company JIRA')
100
101
# Get application links
102
app_links = jira.applicationlinks()
103
for link in app_links:
104
print(f"App Link: {link['name']} -> {link['displayUrl']}")
105
```
106
107
### Session Management
108
109
Manage user sessions and authentication state.
110
111
```python { .api }
112
def session(self, auth: tuple = None) -> dict:
113
"""
114
Get current session information.
115
116
Parameters:
117
- auth: Optional authentication tuple (username, password)
118
119
Returns:
120
Dictionary containing session details
121
"""
122
123
def kill_session(self) -> dict:
124
"""
125
Destroy the current authenticated session.
126
127
Returns:
128
Response dictionary
129
"""
130
131
def kill_websudo(self) -> dict:
132
"""
133
Destroy current WebSudo session (on-premise only).
134
135
Returns:
136
Response dictionary
137
"""
138
```
139
140
Usage examples:
141
```python
142
# Get session information
143
session_info = jira.session()
144
print(f"Session Name: {session_info['name']}")
145
print(f"Login Info: {session_info['loginInfo']}")
146
147
# End current session
148
response = jira.kill_session()
149
print("Session terminated")
150
151
# Kill WebSudo session (on-premise only)
152
try:
153
jira.kill_websudo()
154
print("WebSudo session terminated")
155
except Exception as e:
156
print(f"WebSudo not available or failed: {e}")
157
```
158
159
### System Maintenance
160
161
Backup, restore, and reindexing operations for system maintenance.
162
163
```python { .api }
164
def reindex(self, force: bool = False, background: bool = True) -> dict:
165
"""
166
Start JIRA reindexing process.
167
168
Parameters:
169
- force: Force reindex even if already running
170
- background: Run reindex in background
171
172
Returns:
173
Reindex response dictionary
174
"""
175
176
def backup(self, filename: str = 'backup.zip', attachments: bool = False) -> dict:
177
"""
178
Create system backup (cloud only).
179
180
Parameters:
181
- filename: Backup file name
182
- attachments: Include attachments in backup
183
184
Returns:
185
Backup response dictionary
186
"""
187
188
def backup_progress(self) -> dict:
189
"""
190
Get backup progress status (cloud only).
191
192
Returns:
193
Dictionary containing backup progress information
194
"""
195
196
def backup_complete(self) -> bool:
197
"""
198
Check if backup is complete (cloud only).
199
200
Returns:
201
True if backup is complete, False otherwise
202
"""
203
204
def backup_download(self, filename: str = None) -> None:
205
"""
206
Download completed backup file (cloud only).
207
208
Parameters:
209
- filename: Local filename to save backup
210
"""
211
```
212
213
Usage examples:
214
```python
215
# Start background reindex
216
reindex_result = jira.reindex(background=True)
217
print(f"Reindex started: {reindex_result}")
218
219
# Force immediate reindex (use carefully)
220
reindex_result = jira.reindex(force=True, background=False)
221
print("Forced reindex completed")
222
223
# Cloud backup operations
224
if jira.server_info().get('deploymentType') == 'Cloud':
225
# Start backup
226
backup_result = jira.backup(
227
filename='daily_backup.zip',
228
attachments=True
229
)
230
print(f"Backup started: {backup_result}")
231
232
# Check progress
233
import time
234
while not jira.backup_complete():
235
progress = jira.backup_progress()
236
print(f"Backup progress: {progress.get('progress', 'Unknown')}%")
237
time.sleep(30)
238
239
# Download when complete
240
jira.backup_download('local_backup.zip')
241
print("Backup downloaded successfully")
242
```
243
244
### Security & Permissions
245
246
Retrieve security levels and user permissions.
247
248
```python { .api }
249
def security_level(self, id: str) -> dict:
250
"""
251
Get security level details by ID.
252
253
Parameters:
254
- id: Security level ID
255
256
Returns:
257
Security level dictionary
258
"""
259
260
def my_permissions(
261
self,
262
projectKey: str = None,
263
projectId: str = None,
264
issueKey: str = None,
265
issueId: str = None
266
) -> dict:
267
"""
268
Get current user's permissions for project or issue.
269
270
Parameters:
271
- projectKey: Project key to check permissions for
272
- projectId: Project ID to check permissions for
273
- issueKey: Issue key to check permissions for
274
- issueId: Issue ID to check permissions for
275
276
Returns:
277
Dictionary of permissions with boolean values
278
"""
279
```
280
281
Usage examples:
282
```python
283
# Get security level details
284
security_level = jira.security_level('10000')
285
print(f"Security Level: {security_level['name']}")
286
print(f"Description: {security_level['description']}")
287
288
# Check permissions for project
289
project_perms = jira.my_permissions(projectKey='PROJ')
290
print("Project permissions:")
291
for perm, has_perm in project_perms['permissions'].items():
292
if has_perm:
293
print(f" ✓ {perm}")
294
295
# Check permissions for specific issue
296
issue_perms = jira.my_permissions(issueKey='PROJ-123')
297
print("Issue permissions:")
298
for perm, has_perm in issue_perms['permissions'].items():
299
if has_perm:
300
print(f" ✓ {perm}")
301
302
# Check if user can create issues in project
303
can_create = project_perms['permissions'].get('CREATE_ISSUES', False)
304
print(f"Can create issues: {can_create}")
305
```
306
307
### Universal Resource Finder
308
309
Generic method for accessing any JIRA REST resource.
310
311
```python { .api }
312
def find(self, resource_format: str, ids: tuple = None) -> dict:
313
"""
314
Universal resource locator for any REST resource in JIRA.
315
316
Parameters:
317
- resource_format: REST API resource path format
318
- ids: Tuple of IDs to substitute in resource format
319
320
Returns:
321
Resource dictionary
322
"""
323
```
324
325
Usage examples:
326
```python
327
# Access custom REST endpoints
328
custom_resource = jira.find('rest/api/2/customendpoint/{0}', ('12345',))
329
330
# Access plugin-specific endpoints
331
plugin_data = jira.find('rest/scriptrunner/latest/custom/getData')
332
333
# Access advanced configuration
334
config_data = jira.find('rest/api/2/configuration')
335
```
336
337
## System Information Examples
338
339
Common system information retrieval patterns:
340
341
```python
342
# Comprehensive system status check
343
def system_health_check(jira_client):
344
"""Perform basic system health check."""
345
try:
346
# Server info
347
server_info = jira_client.server_info()
348
print(f"✓ Server: {server_info['version']} (Build {server_info['buildNumber']})")
349
350
# Current user
351
user = jira_client.myself()
352
print(f"✓ Authentication: {user.displayName}")
353
354
# Session info
355
session = jira_client.session()
356
print(f"✓ Session: {session['name']}")
357
358
# Basic permissions
359
perms = jira_client.my_permissions()
360
admin_perms = ['ADMINISTER', 'SYSTEM_ADMIN']
361
is_admin = any(perms['permissions'].get(p, False) for p in admin_perms)
362
print(f"✓ Admin permissions: {is_admin}")
363
364
return True
365
except Exception as e:
366
print(f"✗ Health check failed: {e}")
367
return False
368
369
# Run health check
370
health_check_passed = system_health_check(jira)
371
```
372
373
## Maintenance Operations
374
375
System maintenance automation:
376
377
```python
378
# Scheduled maintenance routine
379
def scheduled_maintenance(jira_client):
380
"""Perform scheduled maintenance tasks."""
381
print("Starting scheduled maintenance...")
382
383
# 1. Create backup (cloud only)
384
try:
385
backup_result = jira_client.backup(
386
filename=f'scheduled_backup_{datetime.now().strftime("%Y%m%d")}.zip',
387
attachments=False
388
)
389
print("✓ Backup initiated")
390
except Exception as e:
391
print(f"⚠ Backup skipped: {e}")
392
393
# 2. Reindex if needed
394
try:
395
reindex_result = jira_client.reindex(background=True)
396
print("✓ Reindex started")
397
except Exception as e:
398
print(f"⚠ Reindex failed: {e}")
399
400
# 3. Check application properties
401
try:
402
props = jira_client.application_properties()
403
important_props = ['jira.title', 'jira.baseurl']
404
for prop in important_props:
405
value = props.get(prop, 'Not set')
406
print(f"✓ {prop}: {value}")
407
except Exception as e:
408
print(f"⚠ Property check failed: {e}")
409
410
print("Maintenance routine completed")
411
412
# Run maintenance
413
scheduled_maintenance(jira)
414
```
415
416
## Security Best Practices
417
418
When performing administrative operations:
419
420
```python
421
# Always verify permissions before admin operations
422
def safe_admin_operation(jira_client, operation_func, *args, **kwargs):
423
"""Safely perform admin operation with permission check."""
424
try:
425
# Check if user has admin permissions
426
perms = jira_client.my_permissions()
427
is_admin = perms['permissions'].get('ADMINISTER', False)
428
429
if not is_admin:
430
raise PermissionError("Admin permissions required")
431
432
# Perform operation
433
result = operation_func(*args, **kwargs)
434
print(f"✓ Admin operation completed successfully")
435
return result
436
437
except Exception as e:
438
print(f"✗ Admin operation failed: {e}")
439
raise
440
441
# Example usage
442
try:
443
safe_admin_operation(
444
jira,
445
jira.set_application_property,
446
'jira.title',
447
'Updated Title'
448
)
449
except Exception as e:
450
print(f"Could not update property: {e}")
451
```