44(Specifically the rest_cherrypy netapi module.)
55
66'''
7- import functools
87import json
98import logging
10- import os
119import ssl
1210try :
1311 ssl ._create_default_https_context = ssl ._create_stdlib_context
@@ -90,9 +88,8 @@ def req_get(self, path):
9088 print(api.login('salt','salt','pam'))
9189 print(api.req_get('/keys'))
9290 '''
93-
9491 import requests
95-
92+
9693 headers = {
9794 'Accept' : 'application/json' ,
9895 'Content-Type' : 'application/json' ,
@@ -110,7 +107,7 @@ def req_get(self, path):
110107 'verify' : self ._ssl_verify == True ,
111108 }
112109 try :
113- resp = requests .get (** params )
110+ resp = requests .get (** params )
114111
115112 if resp .status_code == 401 :
116113 raise PepperException (str (resp .status_code ) + ':Authentication denied' )
@@ -127,7 +124,7 @@ def req_get(self, path):
127124 print (e )
128125 return
129126 return resp .json ()
130-
127+
131128 def req (self , path , data = None ):
132129 '''
133130 A thin wrapper around urllib2 to send requests and return the response
@@ -361,6 +358,27 @@ def runner(self, fun, **kwargs):
361358
362359 return self .low ([low ], path = '/' )
363360
361+ def wheel (self , fun , arg = None , kwarg = None , ** kwargs ):
362+ '''
363+ Run a single command using the ``wheel`` client
364+
365+ Usage::
366+ wheel('key.accept', match='myminion')
367+ '''
368+ low = {
369+ 'client' : 'wheel' ,
370+ 'fun' : fun ,
371+ }
372+
373+ if arg :
374+ low ['arg' ] = arg
375+ if kwarg :
376+ low ['kwarg' ] = kwarg
377+
378+ low .update (kwargs )
379+
380+ return self .low ([low ], path = '/' )
381+
364382 def login (self , username , password , eauth ):
365383 '''
366384 Authenticate with salt-api and return the user permissions and
0 commit comments