import os import json from backendAPIs import ( get_token, get_role_id, update_onboarding_status, get_onboarding_status ) def initialize_onboarding(): print(f"Getting Auth token...") token = get_token() # print(f"Token {token}") onboarding_id = os.getenv('ONBOARDING_ID') print(f"Get onBoardingStatus for {onboarding_id}") response = get_onboarding_status(onboarding_id) if 'error' in response: print(f"Failed to fetch entityid: Error: {response['error']}") print(f"Status Code: {response['status_code']}") return False onboarding_status = response['data']['data'] print(f"Onboading status {onboarding_status}") entity_id = onboarding_status['entityId'] os.environ["ENTITY_ID"] = entity_id print(f"Entityid set to {entity_id} in the environment") print(f"Getting role id...") response = get_role_id(entity_id) print(response) if 'error' in response: print(f"Failed to fetch role id: Error: {response['error']}") print(f"Status Code: {response['status_code']}") return False role_id = response['data'] os.environ["ROLE_ID"] = role_id print(f"Roleid set to {role_id} in the environment") response = update_onboarding_status(-1, "", "", "") if 'error' in response: print(f"Failed to fetch onboarding status: Error: {response['error']}") print(f"Status Code: {response['status_code']}") return False