Commit f1495806 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki

astakos: change authenticate api call

``/astakos/api/authenticate`` call
does not include any more resource usage in the reply.
(``usage`` request parameter has become obsolete)
The services in order to get the resource usage should call
``/astakos/api/quotas`` instead.
parent 22aabeec
......@@ -20,9 +20,10 @@ Document Revisions
========================= ================================
Revision Description
========================= ================================
0.14 (May 14, 2013) Do not serve user quotas in :ref:`authenticate-api-label`
0.14 (May 02, 2013) Change URIs (keep also the old ones until the next version)
0.13 (January 21, 2013) Extend api to export user presentation & quota information.
0.6 (June 06, 2012) Split service and admin API.
0.6 (June 06, 2012) Split service and user API.
0.1 (Feb 10, 2012) Initial release.
========================= ================================
......@@ -77,7 +78,7 @@ Example reply if request user is authenticated:
.. warning:: The service is also available under ``/im/get_menu``.
It will be removed in the next version.
Admin API Operations
User API Operations
--------------------
The operations described in this chapter allow users to authenticate themselves, send feedback and get user uuid/displayname mappings.
......@@ -105,14 +106,6 @@ Request Header Name Value
X-Auth-Token User authentication token
==================== ===========================
|
====================== =========================
Request Parameter Name Value
====================== =========================
usage (optional)
====================== =========================
Extended information on the user serialized in the json format will be returned:
=========================== ============================
......@@ -127,7 +120,7 @@ auth_token_expires Token expiration date
usage List of user resource usage (if usage request parameter is present)
=========================== ============================
Example reply without `usage` request parameter:
Example reply:
::
......@@ -139,88 +132,6 @@ Example reply without `usage` request parameter:
"auth_token_created": "Wed, 30 May 2012 10:03:37 GMT",
"auth_token_expires": "Fri, 29 Jun 2012 10:03:37 GMT"}
Example reply with `usage` request parameter:
::
{"id": "12",
"displayname": "user@example.com",
"uuid": "a9dc21d2-bcb2-4104-9a9e-402b7c70d6d8",
"email": "[user@example.com]",
"name": "Firstname Lastname",
"auth_token_created": "Wed, 30 May 2012 10:03:37 GMT",
"auth_token_expires": "Fri, 29 Jun 2012 10:03:37 GMT",
"usage": [{"currValue": 4536392,
"display_name": "Storage Space",
"description": "Pithos account diskspace",
"verbose_name": "Storage Space",
"help_text_input_each": "This is the total amount of space on Pithos that will be granted to each user of this Project ", "maxValue": 5368710653,
"pluralized_display_name": "Storage Space",
"report_desc": "Storage Space",
"help_text": "This is the space on Pithos for storing files and VM Images. ",
"is_abbreviation": false,
"placeholder": "eg. 10GB",
"unit": "bytes",
"name": "pithos+.diskspace"},
{"currValue": 0,
"display_name": "System Disk",
"description": "Virtual machine disk size",
"verbose_name": "System Disk",
"help_text_input_each": "This is the total amount of System Disk that will be granted to each user of this Project (this refers to the total System Disk of all VMs, not each VM's System Disk) ",
"maxValue": 53687091200,
"pluralized_display_name": "System Disk",
"report_desc": "System Disk",
"help_text": "This is the System Disk that the VMs have that run the OS ",
"is_abbreviation": false,
"placeholder": "eg. 5GB, 2GB etc",
"unit": "bytes",
"name": "cyclades.disk"},
{"currValue": 0,
"display_name": "CPU",
"description": "Number of virtual machine processors",
"verbose_name": "cpu",
"help_text_input_each": "This is the total number of CPUs that will be granted to each user of this Project (on all VMs) ", "maxValue": 6, "pluralized_display_name": "CPUs",
"report_desc": "CPUs",
"help_text": "CPUs used by VMs ",
"is_abbreviation": true,
"placeholder": "eg. 1",
"unit": "",
"name": "cyclades.cpu"},
{"currValue": 0,
"display_name": "RAM",
"description": "Virtual machines",
"verbose_name": "ram",
"help_text_input_each": "This is the total amount of RAM that will be granted to each user of this Project (on all VMs) ", "maxValue": 6442450944,
"pluralized_display_name": "RAM",
"report_desc": "RAM",
"help_text": "RAM used by VMs ",
"is_abbreviation": true,
"placeholder": "eg. 4GB",
"unit": "bytes", "name": "cyclades.ram"},
{"currValue": 0, "display_name": "VM",
"description": "Number of virtual machines",
"verbose_name": "vm", "help_text_input_each": "This is the total number of VMs that will be granted to each user of this Project ", "maxValue": 2,
"pluralized_display_name": "VMs",
"report_desc": "Virtual Machines",
"help_text": "These are the VMs one can create on the Cyclades UI ",
"is_abbreviation": true, "placeholder": "eg. 2",
"unit": "",
"name": "cyclades.vm"},
{"currValue": 0,
"display_name": "private network",
"description": "Private networks",
"verbose_name": "private network",
"help_text_input_each": "This is the total number of Private Networks that will be granted to each user of this Project ",
"maxValue": 1,
"pluralized_display_name": "private networks",
"report_desc": "Private Networks",
"help_text": "These are the Private Networks one can create on the Cyclades UI. ",
"is_abbreviation": false,
"placeholder": "eg. 1",
"unit": "",
"name": "cyclades.network.private"}]}
|
=========================== =====================
......@@ -244,7 +155,7 @@ Post user feedback.
========================= ========= ==================
Uri Method Description
========================= ========= ==================
``astakos/api/feedback`` POST Send feedback
``/astakos/api/feedback`` POST Send feedback
========================= ========= ==================
|
......@@ -276,6 +187,9 @@ Return Code Description
500 (Internal Server Error) The request cannot be completed because of an internal error
=========================== =====================
.. warning:: The service is also available under ``/feedback``.
It will be removed in the next version.
Get User catalogs
^^^^^^^^^^^^^^^^^
......@@ -284,7 +198,7 @@ Return a json formatted dictionary containing information about a specific user
================================ ========= ==================
Uri Method Description
================================ ========= ==================
``astakos/api/user_catalogs`` POST Get 2 catalogs containing uuid to displayname mapping and the opposite
``/astakos/api/user_catalogs`` POST Get 2 catalogs containing uuid to displayname mapping and the opposite
================================ ========= ==================
|
......@@ -327,6 +241,9 @@ Return Code Description
500 (Internal Server Error) The request cannot be completed because of an internal error
=========================== =====================
.. warning:: The service is also available under ``/user_catalogs``.
It will be removed in the next version.
Service API Operations
----------------------
......@@ -342,7 +259,7 @@ Return a json formatted dictionary containing information about a specific user
===================================== ========= ==================
Uri Method Description
===================================== ========= ==================
``astakos/api/service/user_catalogs`` POST Get 2 catalogs containing uuid to displayname mapping and the opposite
``/astakos/api/service/user_catalogs`` POST Get 2 catalogs containing uuid to displayname mapping and the opposite
===================================== ========= ==================
|
......@@ -386,3 +303,6 @@ Return Code Description
401 (Unauthorized) Missing or expired or invalid service token
500 (Internal Server Error) The request cannot be completed because of an internal error
=========================== =====================
.. warning:: The service is also available under ``/service/api/user_catalogs``.
It will be removed in the next version.
......@@ -41,7 +41,6 @@ from snf_django.lib import api
from snf_django.lib.api import faults
from astakos.im.util import epoch
from astakos.im.models import Resource
from astakos.im.quotas import get_user_quotas
from .util import (
......@@ -88,34 +87,6 @@ def authenticate(request):
'auth_token_created': epoch(user.auth_token_created),
'auth_token_expires': epoch(user.auth_token_expires)}
# append usage data if requested
if request.REQUEST.get('usage', None):
quotas = get_user_quotas(user)['system']
usage = []
for k in quotas:
service, _, resource = k.partition('.')
try:
resource = Resource.objects.select_related().get(
service__name=service, name=k)
except Resource.DoesNotExist:
logger.error("Resource %s not found!" % k)
continue
usage.append(dict(
name=k,
description=resource.desc,
unit=resource.unit or '',
help_text=resource.help_text,
help_text_input_each=resource.help_text_input_each,
is_abbreviation=resource.is_abbreviation,
report_desc=resource.report_desc,
placeholder=resource.placeholder,
verbose_name=resource.verbose_name,
display_name=resource.display_name,
pluralized_display_name=resource.pluralized_display_name,
maxValue=quotas[k]['usage'],
currValue=quotas[k]['limit']))
user_info['usage'] = usage
response.content = json.dumps(user_info)
response['Content-Type'] = 'application/json; charset=UTF-8'
response['Content-Length'] = len(response.content)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment