#!/usr/bin/python
"""An example demonstrating the client-side usage
of the cretificate request API endpoint.
"""

import requests, sys

url = 'https://spire.cloudfleet.io/dashboard/blimp/api/request_cert'
domain = sys.argv[1]
secret = sys.argv[2]
file_path = sys.argv[3]
print('requesting: ' + url)
files = {'signature': open(file_path, 'rb')}
r = requests.post(url, {'domain': domain, 'secret': secret}, files=files)

#if r.status_code < 400: # how it should be
if r.json()["success"]:
    print('Success: %s' % r.text)
    quit(0)
else:
    print('Error: %s' % r.text)
    quit(1)

@@ -296,29 +296,12 @@
 rl)%0A
-files = %7B'signature':
+with
  ope
@@ -318,17 +318,70 @@
 h, 'rb')
-%7D
+ as cert_req_file:%0A    cert_req = cert_req_file.read()
 %0Ar = req
@@ -435,22 +435,31 @@
 cret
-%7D
 , 
-files=files
+'cert_req': cert_req%7D
 )%0A%0A#

use new json api to request cert