def api_GET(api_url, api_path, api_key):
    full_url = api_url + "/" + api_path
    response = requests.get(full_url,
                            headers={
                                'Authorization':
                                BaseController.authorization_header(api_key),
                                'accept':
                                'application/json'
                            },
                            verify=False)

    if response.status_code != 200:
        raise Exception("Failed /" + full_url + " retrieval, status " +
                        str(response.status_code) + ": " +
                        str(response.reason))

    return json.loads(str(response.content, 'utf-8').strip())
def auth_cert_registration_global_configuration_update_received(config):
    def registered_auth_key(key):
        return default_auth_key_label(config["security_server"][0]) == key['label'] and \
               'REGISTERED' == key['certificates'][0]['status']

    api_key = os.getenv(config["security_server"][0]["api_key"], "")
    result = requests.get(
        config["security_server"][0]["url"] + "/tokens/" +
        str(config["security_server"][0]['software_token_id']),
        None,
        headers={
            'Authorization': BaseController.authorization_header(api_key),
            'accept': 'application/json'
        },
        verify=False)

    if result.status_code != 200:
        raise Exception("Failed registration status check, status " +
                        str(result.status_code) + ": " + str(result.reason))

    response = json.loads(result.content)
    registered_auth_keys = list(filter(registered_auth_key, response['keys']))
    return bool(registered_auth_keys)
def get_client(config):
    conn_type = convert_swagger_enum(
        ConnectionType,
        config['security_server'][0]['clients'][0]['connection_type'])
    member_class = config['security_server'][0]['clients'][0]['member_class']
    member_code = config['security_server'][0]['clients'][0]['member_code']
    subsystem_code = config['security_server'][0]['clients'][0][
        'subsystem_code']
    api_key = os.getenv(config["security_server"][0]["api_key"], "")
    client = requests.get(config["security_server"][0]["url"] + "/clients", {
        'member_class': member_class,
        'member_code': member_code,
        'subsystem_code': subsystem_code,
        'connection_type': conn_type
    },
                          headers={
                              'Authorization':
                              BaseController.authorization_header(api_key),
                              'accept':
                              'application/json'
                          },
                          verify=False)
    client_json = json.loads(str(client.content, 'utf-8').strip())
    return client_json[0]