def get_repo(repo_id): """ Returns a Repo's information (if the user has access to it). """ username = current_identity.username try: repo_details = _get_repo_details(username, repo_id) except Exception as e: return make_error("Error while getting the details for this repo: " + str(e)) return make_success(repo_details)
def reset_state(repo_id): """ Authorize request, then reset state for cloud node corresponding to given repo_id """ username = current_identity.username try: repo_details = _get_repo_details(username, repo_id) is_demo = repo_details["IsDemo"] reset_cloud_node(repo_id, is_demo) except Exception as e: return make_error("Error resetting state: " + str(e)) return make_success(repo_id)
def get_task_status(repo_id): """ Returns the status of the Cloud Node associated to a Repo the user has access to. """ username = current_identity.username try: repo_details = _get_repo_details(username, repo_id) task_arns = [repo_details["CloudTaskArn"], repo_details["ExploraTaskArn"]] is_demo = repo_details["IsDemo"] status = get_status(task_arns, repo_id, is_demo) except Exception as e: return make_error("Error checking status: " + str(e)) return make_success(status)
def reset_state(repo_id): """ Authorize request, then reset state for cloud node corresponding to given repo_id """ claims = authorize_user(request) if claims is None: return make_unauthorized_error() user_id = claims["pk"] try: repo_details = _get_repo_details(user_id, repo_id) is_demo = repo_details["IsDemo"] reset_cloud_node(repo_id, is_demo) except Exception as e: return make_error("Error resetting state: " + str(e)) return make_success(repo_id)
def get_repo(repo_id): """ Returns a Repo's information (if the user has access to it). """ # Check authorization claims = authorize_user(request) if claims is None: return make_unauthorized_error() # Get data user_id = claims["pk"] try: repo_details = _get_repo_details(user_id, repo_id) except Exception as e: return make_error("Error while getting the details for this repo: " + str(e)) return make_success(repo_details)
def get_task_status(repo_id): """ Returns the status of the Cloud Node associated to a Repo the user has access to. """ # Check authorization claims = authorize_user(request) if claims is None: return make_unauthorized_error() # Get data user_id = claims["pk"] try: repo_details = _get_repo_details(user_id, repo_id) task_arns = [ repo_details["CloudTaskArn"], repo_details["ExploraTaskArn"] ] is_demo = repo_details["IsDemo"] status = get_status(task_arns, repo_id, is_demo) except Exception as e: return make_error("Error checking status: " + str(e)) return make_success(status)
def _delete_repo(user_id, repo_id): """ Helper function to delete repo. """ repo_details = _get_repo_details(user_id, repo_id) cloud_task_arn = repo_details["CloudTaskArn"] cloud_ip_address = repo_details["CloudIpAddress"] explora_task_arn = repo_details["ExploraTaskArn"] explora_ip_address = repo_details["ExploraIpAddress"] is_demo = repo_details["IsDemo"] task_arns = [explora_task_arn] \ if is_demo else [cloud_task_arn, explora_task_arn] ip_addresses = [explora_ip_address] \ if is_demo else [cloud_ip_address, explora_ip_address] _remove_logs(repo_id) _remove_repo_from_user_details(user_id, repo_id) _remove_repo_details(user_id, repo_id) stop_nodes(task_arns, ip_addresses, repo_id, is_demo) return repo_details