def get_root_workflows(username): """ Returns a collection of root level workflows. :query int start-index: Return results starting from record <start-index> (0 indexed) :query int max-results: Return a maximum of <max-results> records :query string query: Search criteria :query string order: Sorting criteria :query boolean pretty-print: Return formatted JSON response. :statuscode 200: OK :statuscode 204: No content; when no workflows found. :statuscode 400: Bad request :statuscode 401: Authentication failure :statuscode 403: Authorization failure :return type: Collection :return resource: Root Workflow """ queries = MasterWorkflowQueries(g.master_db_url) paged_response = queries.get_root_workflows(**g.query_args) if paged_response.total_records == 0: log.debug('Total records is 0; returning HTTP 204 No content') return make_response('', 204, JSON_HEADER) # # Generate JSON Response # response_json = jsonify(paged_response) return make_response(response_json, 200, JSON_HEADER)
def compute_stampede_db_url(): """ If the requested endpoint requires connecting to a STAMPEDE database, then determine STAMPEDE DB URL and store it in g.stampede_db_url. Also, set g.m_wf_id to be the root workflow's uuid """ if "/workflow" not in request.path or "m_wf_id" not in g: return md5sum = hashlib.md5() md5sum.update(g.master_db_url.encode("utf-8")) m_wf_id = g.m_wf_id def _get_cache_key(key_suffix): return "%s.%s" % (md5sum.hexdigest(), key_suffix) cache_key = _get_cache_key(m_wf_id) if cache.get(cache_key): log.debug("Cache Hit: compute_stampede_db_url %s" % cache_key) root_workflow = cache.get(cache_key) else: log.debug("Cache Miss: compute_stampede_db_url %s" % cache_key) queries = MasterWorkflowQueries(g.master_db_url) root_workflow = queries.get_root_workflow(m_wf_id) queries.close() cache.set(_get_cache_key(root_workflow.wf_id), root_workflow, timeout=600) cache.set(_get_cache_key(root_workflow.wf_uuid), root_workflow, timeout=600) g.url_m_wf_id = root_workflow.wf_id g.m_wf_id = root_workflow.wf_uuid g.stampede_db_url = root_workflow.db_url
def get_root_workflows(username): """ Returns a collection of root level workflows. :query int start-index: Return results starting from record <start-index> (0 indexed) :query int max-results: Return a maximum of <max-results> records :query string query: Search criteria :query string order: Sorting criteria :query boolean pretty-print: Return formatted JSON response. :statuscode 200: OK :statuscode 204: No content; when no workflows found. :statuscode 400: Bad request :statuscode 401: Authentication failure :statuscode 403: Authorization failure :return type: Collection :return resource: Root Workflow """ queries = MasterWorkflowQueries(g.master_db_url) paged_response = queries.get_root_workflows(**g.query_args) if paged_response.total_records == 0: log.debug("Total records is 0; returning HTTP 204 No content") return make_response("", 204, JSON_HEADER) # # Generate JSON Response # response_json = jsonify(paged_response) return make_response(response_json, 200, JSON_HEADER)
def compute_stampede_db_url(): """ If the requested endpoint requires connecting to a STAMPEDE database, then determine STAMPEDE DB URL and store it in g.stampede_db_url. Also, set g.m_wf_id to be the root workflow's uuid """ if '/workflow' not in request.path or 'm_wf_id' not in g: return md5sum = hashlib.md5() md5sum.update(g.master_db_url) m_wf_id = g.m_wf_id def _get_cache_key(key_suffix): return '%s.%s' % (md5sum.hexdigest(), key_suffix) cache_key = _get_cache_key(m_wf_id) if cache.get(cache_key): log.debug('Cache Hit: compute_stampede_db_url %s' % cache_key) root_workflow = cache.get(cache_key) else: log.debug('Cache Miss: compute_stampede_db_url %s' % cache_key) queries = MasterWorkflowQueries(g.master_db_url) root_workflow = queries.get_root_workflow(m_wf_id) queries.close() cache.set(_get_cache_key(root_workflow.wf_id), root_workflow, timeout=600) cache.set(_get_cache_key(root_workflow.wf_uuid), root_workflow, timeout=600) g.url_m_wf_id = root_workflow.wf_id g.m_wf_id = root_workflow.wf_uuid g.stampede_db_url = root_workflow.db_url
def get_root_workflow(username, m_wf_id): """ Returns root level workflow identified by m_wf_id. :query boolean pretty-print: Return formatted JSON response. :statuscode 200: OK :statuscode 401: Authentication failure :statuscode 403: Authorization failure :statuscode 404: Not found :return type: Record :return resource: Root Workflow """ queries = MasterWorkflowQueries(g.master_db_url) record = queries.get_root_workflow(m_wf_id) # # Generate JSON Response # response_json = jsonify(record) return make_response(response_json, 200, JSON_HEADER)