forked from sysdiglabs/sysdig-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_policy.py
More file actions
executable file
·43 lines (34 loc) · 817 Bytes
/
update_policy.py
File metadata and controls
executable file
·43 lines (34 loc) · 817 Bytes
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
#!/usr/bin/env python
#
# Update a specific policy
#
import os
import sys
import json
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))
from sdcclient import SdSecureClient
def usage():
print 'usage: %s <sysdig-token>' % sys.argv[0]
print 'Reads json representing updated policy from standard input'
print 'You can find your token at https://secure.sysdig.com/#/settings/user'
sys.exit(1)
#
# Parse arguments
#
if len(sys.argv) != 2:
usage()
sdc_token = sys.argv[1]
policy_json = sys.stdin.read()
#
# Instantiate the SDC client
#
sdclient = SdSecureClient(sdc_token, 'https://secure.sysdig.com')
res = sdclient.update_policy(policy_json)
#
# Return the result
#
if res[0]:
print json.dumps(res[1], indent=2)
else:
print res[1]
sys.exit(1)