I'm attempting to modify a saved search's permissions through the Splunk Python SDK. Unfortunately, it doesn't seem to be supported out of the box, so I'm trying to do it through the REST API. I asked a previous question (modifying saved search permissions using the python sdk) which showed me how to do it in Java, but I'm having trouble translating that solution to Python. I'm using the urllib2 module. I've had some success with this, but I'm stuck:
def modify_perms( ss ):
service = initSplunk()
zen_config = get_config()
url = "localhost:8089/servicesNS/%s/splenoss/saved/searches/%s/acl" % ("admin", ss)
request = urllib2.Request( url )
base64string = base64.encodestring("admin:changeme")
request.add_header("Authorization", "Basic %s" % base64string)
request.add_header("Referer", url )
# Saved search access params
jwargs = { "sharing" : "app" ,
"modifiable" : "1" ,
"perms.read" : "*" ,
"perms.write" : ["admin" , "power"] ,
#"perms" : {"read":["*"] , "write":["admin" , "power"]} ,
}
#response = urllib2.urlopen( request , **jwargs )
response = urllib2.urlopen( request )
print response.read()
If I don't try to push anything to splunk, I get a response back, which has all of the permission settings. However, once I do try to push jwargs, I get error messages about unexpected keywords. I'm assuming that I'm not passing jwargs correctly, or the way I've built jwargs isn't correct. What am I missing to get this to work in Python?
... View more