@@ -12,7 +12,7 @@ def __init__(self, url, username, password):
1212 self .username = username
1313 self .password = password
1414
15- def log_curl_debug (self , method , path , headers = {}, data = None , level = logging .DEBUG ):
15+ def log_curl_debug (self , method , path , data = None , headers = {} , level = logging .DEBUG ):
1616 message = "curl --silent -X {method} -u '{username}':'{password}' -H {headers} {data} '{url}'" .format (
1717 method = method ,
1818 username = self .username ,
@@ -22,9 +22,9 @@ def log_curl_debug(self, method, path, headers={}, data=None, level=logging.DEBU
2222 url = '{0}{1}' .format (self .url , path ))
2323 log .log (level = level , msg = message )
2424
25- def request (self , method = 'GET' , path = '/' ,
26- headers = {'Content-Type' : 'application/json' , 'Accept' : 'application/json' }, data = None ):
27- self .log_curl_debug (method , path , headers , data )
25+ def request (self , method = 'GET' , path = '/' , data = None ,
26+ headers = {'Content-Type' : 'application/json' , 'Accept' : 'application/json' }):
27+ self .log_curl_debug (method = method , path = path , headers = headers , data = data )
2828 response = requests .request (
2929 method = method ,
3030 url = '{0}{1}' .format (self .url , path ),
@@ -33,24 +33,24 @@ def request(self, method='GET', path='/',
3333 auth = (self .username , self .password ),
3434 timeout = 60 )
3535 if response .status_code != 200 :
36- self .log_curl_debug (method , path , headers , data , level = logging .WARNING )
36+ self .log_curl_debug (method = method , path = path , headers = headers , data = data , level = logging .WARNING )
3737 log .warning (response .json ())
3838 response .raise_for_status ()
3939 else :
4040 log .debug ('Received: {0}' .format (response .json ()))
4141 return response
4242
43- def get (self , path , headers = {'Content-Type' : 'application/json' , 'Accept' : 'application/json' }):
44- return self .request ('GET' , path , headers ).json ()
43+ def get (self , path , data = None , headers = {'Content-Type' : 'application/json' , 'Accept' : 'application/json' }):
44+ return self .request ('GET' , path = path , data = data , headers = headers ).json ()
4545
46- def post (self , path , headers = {'Content-Type' : 'application/json' , 'Accept' : 'application/json' }, data = None ):
47- return self .request ('POST' , path , headers , data ).json ()
46+ def post (self , path , data = None , headers = {'Content-Type' : 'application/json' , 'Accept' : 'application/json' }):
47+ return self .request ('POST' , path = path , data = data , headers = headers ).json ()
4848
49- def put (self , path , headers = {'Content-Type' : 'application/json' , 'Accept' : 'application/json' }, data = None ):
50- return self .request ('PUT' , path , headers , data ).json ()
49+ def put (self , path , data = None , headers = {'Content-Type' : 'application/json' , 'Accept' : 'application/json' }):
50+ return self .request ('PUT' , path = path , data = data , headers = headers ).json ()
5151
52- def delete (self , path , headers = {'Content-Type' : 'application/json' , 'Accept' : 'application/json' }):
53- return self .request ('DELETE' , path , headers ).json ()
52+ def delete (self , path , data = None , headers = {'Content-Type' : 'application/json' , 'Accept' : 'application/json' }):
53+ return self .request ('DELETE' , path = path , data = data , headers = headers ).json ()
5454
5555
5656from .confluence import Confluence
0 commit comments