Statistics
| Branch: | Tag: | Revision:

root / kamaki / clients / astakos.py @ b482315a

History | View | Annotate | Download (2 kB)

1 43ca98ee Giorgos Verigakis
# Copyright 2012 GRNET S.A. All rights reserved.
2 43ca98ee Giorgos Verigakis
#
3 43ca98ee Giorgos Verigakis
# Redistribution and use in source and binary forms, with or
4 43ca98ee Giorgos Verigakis
# without modification, are permitted provided that the following
5 43ca98ee Giorgos Verigakis
# conditions are met:
6 43ca98ee Giorgos Verigakis
#
7 43ca98ee Giorgos Verigakis
#   1. Redistributions of source code must retain the above
8 43ca98ee Giorgos Verigakis
#      copyright notice, this list of conditions and the following
9 43ca98ee Giorgos Verigakis
#      disclaimer.
10 43ca98ee Giorgos Verigakis
#
11 43ca98ee Giorgos Verigakis
#   2. Redistributions in binary form must reproduce the above
12 43ca98ee Giorgos Verigakis
#      copyright notice, this list of conditions and the following
13 43ca98ee Giorgos Verigakis
#      disclaimer in the documentation and/or other materials
14 43ca98ee Giorgos Verigakis
#      provided with the distribution.
15 43ca98ee Giorgos Verigakis
#
16 43ca98ee Giorgos Verigakis
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 43ca98ee Giorgos Verigakis
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 43ca98ee Giorgos Verigakis
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 43ca98ee Giorgos Verigakis
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 43ca98ee Giorgos Verigakis
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 43ca98ee Giorgos Verigakis
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 43ca98ee Giorgos Verigakis
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 43ca98ee Giorgos Verigakis
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 43ca98ee Giorgos Verigakis
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 43ca98ee Giorgos Verigakis
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 43ca98ee Giorgos Verigakis
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 43ca98ee Giorgos Verigakis
# POSSIBILITY OF SUCH DAMAGE.
28 43ca98ee Giorgos Verigakis
#
29 43ca98ee Giorgos Verigakis
# The views and conclusions contained in the software and
30 43ca98ee Giorgos Verigakis
# documentation are those of the authors and should not be
31 43ca98ee Giorgos Verigakis
# interpreted as representing official policies, either expressed
32 43ca98ee Giorgos Verigakis
# or implied, of GRNET S.A.
33 43ca98ee Giorgos Verigakis
34 c270fe96 Stavros Sachtouris
from kamaki.clients import Client, ClientError
35 43ca98ee Giorgos Verigakis
36 3dabe5d2 Stavros Sachtouris
37 43ca98ee Giorgos Verigakis
class AstakosClient(Client):
38 43ca98ee Giorgos Verigakis
    """GRNet Astakos API client"""
39 44b8928d Giorgos Verigakis
40 2f749e6e Stavros Sachtouris
    def __init__(self, base_url, token):
41 33dc6317 Stavros Sachtouris
        super(AstakosClient, self).__init__(base_url, token)
42 2f749e6e Stavros Sachtouris
43 0238c167 Stavros Sachtouris
    def authenticate(self, token=None):
44 0d79eb23 Stavros Sachtouris
        """
45 0d79eb23 Stavros Sachtouris
        :param token: (str) custom token to authenticate
46 0d79eb23 Stavros Sachtouris

47 0d79eb23 Stavros Sachtouris
        :returns: (dict) authentication information
48 0d79eb23 Stavros Sachtouris
        """
49 0238c167 Stavros Sachtouris
        if token:
50 0238c167 Stavros Sachtouris
            self.token = token
51 43ca98ee Giorgos Verigakis
        r = self.get('/im/authenticate')
52 43ca98ee Giorgos Verigakis
        return r.json