-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVSA.py
More file actions
769 lines (715 loc) · 26.3 KB
/
VSA.py
File metadata and controls
769 lines (715 loc) · 26.3 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
import requests
import datetime
import configparser
from os import getcwd, path
from platform import system
from json import dumps
try:
from . import exceptions
except(ImportError):
import exceptions
config = configparser.ConfigParser()
# For use as submodule. Will likely need a change/detection for pip deployment.
if(system() == "Windows"):
fullpath = getcwd() + "\\PythonVSA\\config.ini"
else:
fullpath = getcwd() + "/PythonVSA/config.ini"
readfiles = config.read(fullpath, encoding='utf-8')
if(not readfiles):
readfiles = config.read('config.ini', encoding='utf-8')
if(not readfiles):
print("We weren't able to read config.ini.")
exit()
try:
vsa_uri = config['VSA']['vsa_uri']
api_uri = vsa_uri + "/api/v1.0/"
redirect_uri = config['Listener']['redirect_uri']
client_id = config['VSA']['client_id']
client_secret = config['VSA']['client_secret']
except(KeyError):
print("You haven't properly initialized this library.")
print("Please ensure you have copied sample_config.ini to config.ini and filled in all the required options.")
exit()
class Auth:
@classmethod
def doRefresh(cls, refresh_token=config['Auth']['refresh_token']):
if(system() == "Windows"):
fullpath = getcwd() + "\\PythonVSA\\config.ini"
else:
fullpath = getcwd() + "/PythonVSA/config.ini"
readfiles = config.read(fullpath, encoding='utf-8')
if(not readfiles):
fullpath = 'config.ini'
readfiles = config.read('config.ini', encoding='utf-8')
if(not readfiles):
print("We weren't able to read config.ini.")
exit()
refreshuri = vsa_uri + "/api/v1.0/token"
print("Refreshing token...")
r = requests.post(refreshuri, json={
"grant_type": "refresh_token",
"refresh_token": refresh_token,
"redirect_uri": redirect_uri,
"client_id": client_id,
"client_secret": client_secret})
if(r.status_code == 400):
print("Please delete the [Auth] section of config.ini and reauthenticate with kaseya.")
# TODO: If refresh_token = line missing just add Auth section with blank refresh_token =
# TODO: If reauth needed just delete the section/ignore it and send a new email. Is there a bettter way of handling this?
print(r.text)
exit()
else:
config['Auth']['refreshed_at'] = datetime.datetime.now().strftime("%Y%m%d%H%M")
config['Auth']['refresh_token'] = r.json()['refresh_token']
config['Auth']['access_token'] = r.json()['access_token']
if(system() == "Windows"):
fullpath = getcwd() + "\\PythonVSA\\config.ini"
else:
fullpath = getcwd() + "/PythonVSA/config.ini"
if(not path.exists(fullpath)):
fullpath = 'config.ini'
with open(fullpath, 'w') as configfile:
config.write(configfile)
print(r.text)
return r.json()['access_token']
@classmethod
def GetToken(cls):
"""Allows access to the authentication token, refreshing when required."""
# TODO: What is the best way of securely storing this token cross platform?
if(system() == "Windows"):
fullpath = getcwd() + "\\PythonVSA\\config.ini"
else:
fullpath = getcwd() + "/PythonVSA/config.ini"
if(not path.exists(fullpath)):
fullpath = 'config.ini'
config.read(fullpath)
try:
refresh_token = config['Auth']['refresh_token']
refreshed_at = config['Auth']['refreshed_at']
access_token = config['Auth']['access_token']
except(KeyError):
print("You haven't properly initialized this library.")
print("Please run VSA_Auth.py to perform initial setup.")
exit()
refreshdelta = int(datetime.datetime.now().strftime("%Y%m%d%H%M")) - int(refreshed_at)
if(refreshdelta >= 20):
print("Refreshing token.")
access_token = Auth.doRefresh(refresh_token)
return access_token
class AgentProcedures:
"""http://help-origin.kaseya.com/webhelp/EN/RESTAPI/9040000/#31639.htm"""
@classmethod
def List(cls, params=None):
"""
Get list of Agent Procedures
http://help-origin.kaseya.com/webhelp/EN/RESTAPI/9040000/#31641.htm
Parameters
----------
params : str
Extra request parameters (http://help-origin.kaseya.com/webhelp/EN/RESTAPI/9040000/#31622.htm)
Returns
-------
dict : JSON Dictionary of Agent Procedures
"""
if(params is None):
url = api_uri + "automation/agentprocs"
else:
url = api_uri + "automation/agentprocs?" + params
r = requests.get(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
return r.json()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def RunNow(cls, agentId, procedureId):
"""
Run an Agent Procedure ASAP
http://help.kaseya.com/webhelp/EN/restapi/9050000/#31668.htm
Parameters
----------
agentId : int
ID of agent to execute procedure on
procedureId : int
ID of agent procedure to execute
Returns
-------
int : 0 on success
"""
url = api_uri + "automation/agentprocs/" + str(agentId) + "/" + str(procedureId) + "/runnow"
r = requests.put(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken()})
if(r.status_code == 204):
return 0
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def GetPrompts(cls, procedureId):
"""Get Agent Procedure Prompts
Parameters
----------
procedureId : int
Procedure to get prompt options against
Returns
-------
dict: Procedure prompts and information
"""
url = api_uri + "automation/agentprocs/" + str(procedureId) + "/prompts"
r = requests.get(url, headers={
"Accept": "*/*",
"Content-Type": "application/json",
"Authorization": "Bearer " + Auth.GetToken()
})
if(r.status_code == 200):
return r.json()
elif(r.status_code == 403):
raise exceptions.AuthError()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def RunNowPrompt(cls, agentId, procedureId, procPrompts):
"""
Run an Agent Procedure ASAP with Parameters Prompts
http://help.kaseya.com/webhelp/EN/restapi/9050000/#31668.htm
https://<server>/api/v1.0/swagger/ui/index#!/AgentProcedure/AgentProcedure_RunNowAgentProc
Parameters
----------
agentId : int
ID of agent to execute procedure on
procedureId : int
ID of agent procedure to execute
procPrompts : dict
See readme.md procprompts section
Returns
-------
int : 0 on success
"""
# Thanks to @tutume for issue #14
url = api_uri + "automation/agentprocs/" + str(agentId) + "/" + str(procedureId) + "/runnow"
r = requests.put(url=url,
headers={
"Accept": "*/*",
"Content-Type": "application/json",
"Authorization": "Bearer " + Auth.GetToken()},
data=dumps(procPrompts)
)
if(r.status_code == 204):
return 0
elif(r.status_code == 403):
raise exceptions.AuthError()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
class Agents:
"""http://help.kaseya.com/webhelp/EN/restapi/9050000/#31621.htm"""
@classmethod
def Find(cls, params):
"""
Find an agentId using a number of parameters
Parameters
----------
params : string
Properly formatted string of filters/expressions (see README)
Returns
-------
list : Found agent(s)
"""
url = api_uri + "/assetmgmt/agents?" + params
r = requests.get(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
data = r.json()['Result']
return data
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def GetAllAlarms(cls, returnAll="true", params=None):
"""
Get all alarms
Parameters
----------
returnAll : string
"true" or "false". True will always download all open alarms, false will only download the alarms this application hasn't downloaded previously.
params : string
Properly formatted string of filters/expressions (see README)
Returns
-------
dict : Dictionary of alarms (http://help.kaseya.com/webhelp/EN/restapi/9050000/#38512.htm)
"""
if(params is None):
url = api_uri + "assetmgmt/alarms/" + returnAll
else:
url = api_uri + "assetmgmt/alarms/" + returnAll + "?" + params
r = requests.get(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
return r.json()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def CloseAlarm(cls, alarmId, reason="PythonVSA"):
"""
Close Alarm
Parameters
----------
alarmId : int
Alarm ID
reason : string
Reason you are closing the alarm
Returns
-------
int : 0 on success
"""
url = api_uri + "assetmgmt/alarms/" + str(alarmId) + "/close"
r = requests.put(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"}, data=[{"key": "notes",
"value": reason}])
if(r.status_code == 200):
return 0
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def GetCustomFields(cls, agentId):
"""
Get all custom fields for an agent
Parameters
----------
agentId : int
Agent ID to query for custom fields
Returns
-------
dict : Dictionary of custom fields and their values
"""
url = f"{api_uri}assetmgmt/assets/{str(agentId)}/customfields"
r = requests.get(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
return r.json()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
try:
error = r.json()["Error"]
if(error == "No custom fields exist for specified agent."):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
except(KeyError):
raise exceptions.VSAError(r.text)
@classmethod
def AddCustomField(cls, FieldName, FieldType):
"""
Create a new custom field
Parameters
----------
FieldName : string
Name of field to create
FieldType : string
Type of field, options are: string, number, date time, date, time
Returns
-------
int : 0 if success
"""
from json import dumps
url = f"{api_uri}assetmgmt/assets/customfields"
data = {"FieldName": FieldName, "FieldType": FieldType}
r = requests.post(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken()},
data=data)
if(r.status_code == 200):
return 0
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def UpdateCustomField(cls, agentId, FieldName, FieldValue):
"""
Update an existing custom field
Parameters
----------
agentId : int
GUID of Kaseya agent to update custom field value of
FieldName : string
Name of field to update
FieldValue : string
Value to insert in chosen field
Returns
-------
int : 0 if success
"""
url = f"{api_uri}assetmgmt/assets/{agentId}/customfields/{FieldName}"
data = {"FieldValue": FieldValue}
r = requests.put(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken()},
data=data)
if(r.status_code == 200):
return 0
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
class ServiceDesk:
"""
http://help-origin.kaseya.com/webhelp/EN/RESTAPI/9040000/#31752.htm
"""
@classmethod
def GetTickets(cls, serviceDeskId, params=None):
"""
Get Tickets based on Service Desk ID
Parameters
----------
serviceDeskId : int
ID of service desk to search
params : string
Properly formatted string of filters/expressions (see README)
Returns
-------
dict : Tickets Found
"""
if(params is None):
url = api_uri + "automation/servicedesks/" + str(serviceDeskId) + "/tickets"
else:
url = api_uri + "automation/servicedesks/" + str(serviceDeskId) + "/tickets?" + params
r = requests.get(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
return r.json()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def GetDesks(cls, params=None):
"""
Get all Service Desks
Parameters
----------
params : string
Properly formatted string of filters/expressions (see README)
Returns
-------
dict : Service Desks Found
"""
if(params is None):
url = api_uri + "automation/servicedesks/"
else:
url = api_uri + "automation/servicedesks/" + params
r = requests.get(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
return r.json()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def GetTicketCategories(cls, serviceDeskId, params=None):
"""
Get Ticket Categories based on Service Desk ID
Parameters
----------
serviceDeskId : int
ID of service desk to search
params : string
Properly formatted string of filters/expressions (see README)
Returns
-------
dict : Ticket categories
"""
if(params is None):
url = api_uri + "automation/servicedesks/" + str(serviceDeskId) + "/categories"
else:
url = api_uri + "automation/servicedesks/" + str(serviceDeskId) + "/categories?" + params
r = requests.get(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
return r.json()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def GetCustomFields(cls, serviceDeskId, params=None):
"""
Get Custom Fields based on Service Desk ID
Parameters
----------
serviceDeskId : int
ID of service desk to search
params : string
Properly formatted string of filters/expressions (see README)
Returns
-------
dict : Custom Fields
"""
if(params is None):
url = api_uri + "automation/servicedesks/" + str(serviceDeskId) + "/customfields"
else:
url = api_uri + "automation/servicedesks/" + str(serviceDeskId) + "/customfields?" + params
r = requests.get(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
return r.json()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def GetPriorities(cls, serviceDeskId, params=None):
"""
Get Service Desk Priorities based on Service Desk ID
Parameters
----------
serviceDeskId : int
ID of service desk to search
params : string
Properly formatted string of filters/expressions (see README)
Returns
-------
dict : Service Desk Priorities
"""
if(params is None):
url = api_uri + "automation/servicedesks/" + str(serviceDeskId) + "/priorities"
else:
url = api_uri + "automation/servicedesks/" + str(serviceDeskId) + "/priorities?" + params
r = requests.get(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
return r.json()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def GetTicketStatuses(cls, serviceDeskId, params=None):
"""
Get Ticket Statuses based on Service Desk ID
Parameters
----------
serviceDeskId : int
ID of service desk to search
params : string
Properly formatted string of filters/expressions (see README)
Returns
-------
dict : Ticket Statuses
"""
if(params is None):
url = api_uri + "automation/servicedesks/" + str(serviceDeskId) + "/status"
else:
url = api_uri + "automation/servicedesks/" + str(serviceDeskId) + "/status?" + params
r = requests.get(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
return r.json()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def GetTicket(cls, ticketId, params=None):
"""
Get Ticket info based on Ticket ID
Parameters
----------
ticketId : int
ID of ticket to retrieve
params : string
Properly formatted string of filters/expressions (see README)
Returns
-------
dict : Ticket Information
"""
if(params is None):
url = api_uri + "automation/servicedesktickets/" + str(ticketId)
else:
url = api_uri + "automation/servicedesktickets/" + str(ticketId) + "?" + params
r = requests.get(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
return r.json()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def GetTicketCustomField(cls, ticketId, customFieldId):
"""
Get Custom Field value from Ticket
Parameters
----------
ticketId : int
Ticket to search for custom field
customFieldId : int
Custom Field ID
Returns
-------
dict : Custom Field Value
"""
url = api_uri + "automation/servicedesktickets/" + str(ticketId) + "/customfields/" + str(customFieldId)
r = requests.get(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
return r.json()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def UpdateCustomField(cls, ticketId, customFieldId, data):
"""
Update Custom Field value on ticket
Parameters
----------
ticketId : int
Ticket to search for custom field
customFieldId : int
ID of custom field to update
data : string
String encapsulated in escaped double quotes to fill custom field
Example: data = '\"Hello World!\"'
Returns
-------
int : 0 if success
"""
url = api_uri + "automation/servicedesktickets/" + str(ticketId) + "/customfields/" + str(customFieldId)
r = requests.put(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"},
data=data)
if(r.status_code == 200):
print("Custom Field Updated.")
return 0
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def GetTicketNotes(cls, ticketId, params=None):
"""
Get Ticket notes based on Ticket ID
Parameters
----------
ticketId : int
ID of ticket to retrieve
params : string
Properly formatted string of filters/expressions (see README)
Returns
-------
list : Ticket Notes
"""
if(params is None):
url = api_uri + "automation/servicedesktickets/" + str(ticketId) + "/notes"
else:
url = api_uri + "automation/servicedesktickets/" + str(ticketId) + "/notes?" + params
r = requests.get(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
print("Ticket Notes retrieved sucessfully.")
return r.json()
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def AddTicketNote(cls, ticketId, note, hidden="true", systemflag="true"):
"""
Add note to ticket
Parameters
----------
ticketId : int
ID of ticket to add note against
note : string
Note to add to ticket
Returns
-------
int : 0 if success
"""
url = api_uri + "automation/servicedesktickets/" + str(ticketId) + "/notes"
data = {"Hidden": hidden,
"SystemFlag": systemflag,
"Text": note}
r = requests.post(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"}, data=data)
if(r.status_code == 200):
return 0
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def UpdateTicketPriority(cls, ticketId, priorityId):
"""
Update Ticket Priority
Parameters
----------
ticketId : int
ID of ticket to change priority of
priorityId : int
Priority to set
Returns
-------
int : 0 if success
"""
url = api_uri + "automation/servicedesktickets/" + str(ticketId) + "/priority/" + str(priorityId)
r = requests.put(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken(),
"Content-Type": "application/json"})
if(r.status_code == 200):
return 0
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)
@classmethod
def UpdateTicketStatus(cls, ticketId, statusId):
"""
Update Ticket Status
Parameters
----------
ticketId : int
ID of ticket to change status of
statusId : int
Status to set
Returns
-------
int : 0 if success
"""
url = api_uri + "automation/servicedesktickets/" + str(ticketId) + "/status/" + str(statusId)
r = requests.put(url=url, headers={
"Authorization": "Bearer " + Auth.GetToken()})
if(r.status_code == 200):
return 0
elif(r.status_code == 404):
raise exceptions.ItemNotFound(r)
else:
raise exceptions.VSAError(r.text)