No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

123456789101112131415161718192021222324252627282930313233343536
  1. import requests
  2. # Querying which actions are available on resource 0 to user with ID 0
  3. r_available = requests.get('http://localhost:8080/available/?resource=0&user=0')
  4. # The result is a JSON object with a key for each action branch, and
  5. # each branch consisting of an array of strings, each element being
  6. # an action name available to that user
  7. print(r_available.json())
  8. # Assuming this is the same resource as added in ** Populating Redis in
  9. # docs/integration.org, the result would be:
  10. # >>> print(ra.json())
  11. # {u'data': [u'no-access', u'view']}
  12. # To perform an action, we use the /run-action endpoint, which takes
  13. # a branch name and action name in addition to the resource and user.
  14. # The result of the /available query tells us exactly which branches and
  15. # actions we can perform
  16. r_view = requests.get('http://localhost:8080/run-action/?resource=0&user=0&branch=data&action=view')
  17. # In this case, the output of the 'view' action is a JSON array representation of the SQL output
  18. print(r_view.json())
  19. # Thus, each of the fields can be accessed as in any other array; for example
  20. # we can retrieve the Phenotype.Pre_publication_description field:
  21. print(r_view.json()[3])
  22. r_na = requests.get('http://localhost:8080/run-action/?resource=0&user=0&branch=data&action=no-access')
  23. # If the user doesn't have access, the string "no-action" is returned,
  24. # as the no-access-action is used by default