示例#1
0
def get(auth_token, base_url, verbose, url):
    api_url = "%s/%s" % (base_url, url)
    output(verbose, "Calling GET on %s" % api_url)
    get_response = requests.get(
        api_url, headers={'Authorization': 'Basic %s' % auth_token})
    if get_response.text != "":
        api_response = json.loads(get_response.text)
        return api_response
    elif 200 <= get_response.status_code < 300:
        return True
    else:
        return False
示例#2
0
def post(auth_token, base_url, verbose, url, data_payload):
    api_url = "%s/%s" % (base_url, url)
    output(verbose, "Calling POST on %s" % api_url)
    post_response = requests.post(api_url,
                                  headers={
                                      'Authorization': 'Basic %s' % auth_token,
                                      'Content-Type': 'application/json'
                                  },
                                  json=data_payload)
    if post_response.text != "":
        api_response = json.loads(post_response.text)
        return api_response
    elif 200 <= post_response.status_code < 300:
        return True
    else:
        return False