Revision b173906e astakosclient/astakosclient/__init__.py
b/astakosclient/astakosclient/__init__.py | ||
---|---|---|
56 | 56 |
|
57 | 57 |
# -------------------------------------------------------------------- |
58 | 58 |
# Astakos API urls |
59 |
UI_PREFIX = get_path(astakos_services, 'astakos_ui.prefix') |
|
59 | 60 |
ACCOUNTS_PREFIX = get_path(astakos_services, 'astakos_account.prefix') |
60 | 61 |
ACCOUNTS_PREFIX = join_urls(ACCOUNTS_PREFIX, 'v1.0') |
61 | 62 |
API_AUTHENTICATE = join_urls(ACCOUNTS_PREFIX, "authenticate") |
62 | 63 |
API_USERCATALOGS = join_urls(ACCOUNTS_PREFIX, "user_catalogs") |
63 | 64 |
API_SERVICE_USERCATALOGS = join_urls(ACCOUNTS_PREFIX, "service/user_catalogs") |
64 |
API_GETSERVICES = join_urls(ACCOUNTS_PREFIX, "get_services")
|
|
65 |
API_GETSERVICES = join_urls(UI_PREFIX, "get_services")
|
|
65 | 66 |
API_RESOURCES = join_urls(ACCOUNTS_PREFIX, "resources") |
66 | 67 |
API_QUOTAS = join_urls(ACCOUNTS_PREFIX, "quotas") |
67 | 68 |
API_SERVICE_QUOTAS = join_urls(ACCOUNTS_PREFIX, "service_quotas") |
... | ... | |
72 | 73 |
# -------------------------------------------------------------------- |
73 | 74 |
# Astakos Keystone API urls |
74 | 75 |
IDENTITY_PREFIX = get_path(astakos_services, 'astakos_identity.prefix') |
76 |
IDENTITY_PREFIX = join_urls(IDENTITY_PREFIX, "v2.0") |
|
75 | 77 |
API_TOKENS = join_urls(IDENTITY_PREFIX, "tokens") |
76 |
TOKENS_ENDPOINTS = join_urls(API_TOKENS, "endpoints") |
|
77 | 78 |
|
78 | 79 |
|
79 | 80 |
# -------------------------------------------------------------------- |
... | ... | |
362 | 363 |
self._call_astakos(token, path, None, req_body, "POST") |
363 | 364 |
|
364 | 365 |
# ---------------------------------- |
365 |
# do a GET to ``API_TOKENS``/<user_token>/``TOKENS_ENDPOINTS`` |
|
366 |
def get_endpoints(self, token, belongs_to=None, marker=None, limit=None): |
|
367 |
"""Request registered endpoints from astakos |
|
368 |
|
|
369 |
keyword arguments: |
|
370 |
token -- user's token (string) |
|
371 |
belongs_to -- user's uuid (string) |
|
372 |
marker -- return endpoints whose ID is higher than marker's (int) |
|
373 |
limit -- maximum number of endpoints to return (int) |
|
374 |
|
|
375 |
Return a json formatted dictionary containing information |
|
376 |
about registered endpoints. |
|
377 |
|
|
378 |
WARNING: This api call encodes the user's token inside the url. |
|
379 |
It's thoughs security unsafe to use it (both astakosclient and |
|
380 |
nginx tend to log requested urls). |
|
381 |
Avoid the use of get_endpoints method and use |
|
382 |
get_user_info_with_endpoints instead. |
|
383 |
|
|
384 |
""" |
|
385 |
params = {} |
|
386 |
if belongs_to is not None: |
|
387 |
params['belongsTo'] = str(belongs_to) |
|
388 |
if marker is not None: |
|
389 |
params['marker'] = str(marker) |
|
390 |
if limit is not None: |
|
391 |
params['limit'] = str(limit) |
|
392 |
path = API_TOKENS + "/" + token + "/" + \ |
|
393 |
TOKENS_ENDPOINTS + "?" + urllib.urlencode(params) |
|
394 |
return self._call_astakos(token, path) |
|
395 |
|
|
396 |
# ---------------------------------- |
|
397 | 366 |
# do a POST to ``API_TOKENS`` |
398 |
def get_user_info_with_endpoints(self, token, uuid=None):
|
|
367 |
def get_endpoints(self, token, uuid=None): |
|
399 | 368 |
""" Fallback call for authenticate |
400 | 369 |
|
401 | 370 |
Keyword arguments: |
Also available in: Unified diff