Esempio n. 1
0
def do_ls(ns):
    response = requests.get(ns.api_url / 'autocert', json=jsonify(ns, destinations=dictify(ns.destinations)))
    if response.status_code == 200:
        json = response.json()
        output(json)
        return
    else:
        print(response)
        print(response.text)
    raise Exception('wtf do_ls')
Esempio n. 2
0
def do_deploy(ns):
    response = requests.put(ns.api_url / 'autocert',
                            json=jsonify(ns,
                                         destinations=dictify(
                                             ns.destinations)))
    if response.status_code == 200:
        certs = response.json().get('certs', [])
        output(certs)
    elif response.status_code == 201:
        certs = response.json().get('certs', [])
        output(certs)
    else:
        print(response)
        print(response.text)
        raise Exception('wtf do_deploy')
Esempio n. 3
0
def do_request(ns):
    method = METHODS[ns.command]
    destinations = dictify(ns.destinations) if hasattr(
        ns, 'destinations') else None
    json = jsonify(ns, destinations=destinations if destinations else None)
    validate(ns.api_url, throw=True)
    response = requests.request(method, ns.api_url / 'autocert', json=json)
    status = response.status_code
    try:
        json = response.json()
        output(json)
    except JSONDecodeError as jde:
        print('status =', status)
        print('JSONDecodeError =', jde)
        print('text =', response.text)
        return -1
    return status