Procházet zdrojové kódy

Python example and dumb bug fixes

Christian Fischer před 4 měsíci
3 změnil soubory, kde provedl 41 přidání a 6 odebrání
  1. +0
  2. +36
  3. +5

+ 0
- 5
docs/ Zobrazit soubor

@@ -1,7 +1,5 @@
* Integration guide/process

[2020-05-19 Tue]

Here I'll be documenting the process of replacing the SQL queries in
GN2's, including creating the proxy resource types, and
populating Redis with resource entries.
@@ -222,9 +220,6 @@ with name "resource1" at Redis ID 0:

Additionally, users and groups have to exist in Redis. We can
use the GN2 users already in Redis from GN2, but for completeness'

** Using the API

+ 36
- 0 Zobrazit soubor

@@ -0,0 +1,36 @@
import requests

# Querying which actions are available on resource 0 to user with ID 0
r_available = requests.get('http://localhost:8080/available/?resource=0&user=0')

# The result is a JSON object with a key for each action branch, and
# each branch consisting of an array of strings, each element being
# an action name available to that user

# Assuming this is the same resource as added in ** Populating Redis in
# docs/, the result would be:

# >>> print(ra.json())
# {u'data': [u'no-access', u'view']}

# To perform an action, we use the /run-action endpoint, which takes
# a branch name and action name in addition to the resource and user.

# The result of the /available query tells us exactly which branches and
# actions we can perform
r_view = requests.get('http://localhost:8080/run-action/?resource=0&user=0&branch=data&action=view')

# In this case, the output of the 'view' action is a JSON array representation of the SQL output

# Thus, each of the fields can be accessed as in any other array; for example
# we can retrieve the Phenotype.Pre_publication_description field:

r_na = requests.get('http://localhost:8080/run-action/?resource=0&user=0&branch=data&action=no-access')

# If the user doesn't have access, the string "no-action" is returned,
# as the no-access-action is used by default

+ 5
- 1
server/resource.rkt Zobrazit soubor

@@ -151,8 +151,12 @@
(action-set (apply-mask (dict-ref resource-types (resource-type res))
(let ((action (assoc action-id (hash-ref action-set branch-id))))
(if action
(cdr action)

(cdr (assoc action-id (hash-ref action-set branch-id)))))
;; (cdr (assoc action-id (hash-ref action-set branch-id)))))

;; The general "no access" action -- may change in the future
(define no-access-action

Načítá se…