You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2023/09/27 18:59:28 UTC
[airavata-cookiecutter-django-app] 06/16: Adding Airavata API client example call
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airavata-cookiecutter-django-app.git
commit 5a38df026aee619f6c9d84ca601091df911a0f03
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Jun 2 13:27:13 2021 -0400
Adding Airavata API client example call
---
{{cookiecutter.project_slug}}/setup.cfg | 1 +
.../{{cookiecutter.project_slug}}/views.py | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg
index cbe2c59..41252a4 100644
--- a/{{cookiecutter.project_slug}}/setup.cfg
+++ b/{{cookiecutter.project_slug}}/setup.cfg
@@ -9,6 +9,7 @@ packages = find:
include_package_data = True
install_requires =
django >= 2.2
+ airavata-django-portal-sdk
[options.entry_points]
airavata.djangoapp =
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/views.py
index 6e47202..764354e 100644
--- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/views.py
+++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/views.py
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseNotFound
from django.shortcuts import render
@@ -9,10 +10,30 @@ from airavata_django_portal_sdk import user_storage
@login_required
def home(request):
+ # Example code: Airavata API client
+ # Make calls to the Airavata API from your view, for example:
+ #
+ # experiments = request.airavata_client.searchExperiments(
+ # request.authz_token, settings.GATEWAY_ID, request.user.username, filters={},
+ # limit=20, offset=0)
+ #
+ # The authorization token is always the first argument of Airavata API calls
+ # and is available as 'request.authz_token'. Some API methods require a
+ # 'gatewayID' argument and that is available on the Django settings object
+ # as 'settings.GATEWAY_ID'.
+ # For documentation on other Airavata API methods, see
+ # https://docs.airavata.org/en/master/technical-documentation/airavata-api/.
+ # The Airavata Django Portal uses the Airavata Python Client SDK:
+ # https://github.com/apache/airavata/tree/master/airavata-api/airavata-client-sdks/airavata-python-sdk
+
+
+ # Example code: user_storage module
# In your Django views, you can make calls to the user_storage module to manage a user's files in the gateway
+ #
# user_storage.listdir(request, "") # lists the user's home directory
# user_storage.open_file(request, data_product_uri=...) # open's a file for a given data_product_uri
# user_storage.save(request, "path/in/user/storage", file) # save a file to a path in the user's storage
+ #
# For more information as well as other user_storage functions, see https://airavata-django-portal-sdk.readthedocs.io/en/latest/
return render(request, "{{ cookiecutter.project_slug }}/home.html", {