Statistics
| Branch: | Tag: | Revision:

root / kamaki / clients / cyclades / rest_api.py @ 264a13f7

History | View | Annotate | Download (5.2 kB)

1 e3f01d64 Stavros Sachtouris
# Copyright 2012-2013 GRNET S.A. All rights reserved.
2 55faa0bc Stavros Sachtouris
#
3 55faa0bc Stavros Sachtouris
# Redistribution and use in source and binary forms, with or
4 55faa0bc Stavros Sachtouris
# without modification, are permitted provided that the following
5 55faa0bc Stavros Sachtouris
# conditions are met:
6 55faa0bc Stavros Sachtouris
#
7 55faa0bc Stavros Sachtouris
#   1. Redistributions of source code must retain the above
8 55faa0bc Stavros Sachtouris
#      copyright notice, this list of conditions and the following
9 55faa0bc Stavros Sachtouris
#      disclaimer.
10 55faa0bc Stavros Sachtouris
#
11 55faa0bc Stavros Sachtouris
#   2. Redistributions in binary form must reproduce the above
12 55faa0bc Stavros Sachtouris
#      copyright notice, this list of conditions and the following
13 55faa0bc Stavros Sachtouris
#      disclaimer in the documentation and/or other materials
14 55faa0bc Stavros Sachtouris
#      provided with the distribution.
15 55faa0bc Stavros Sachtouris
#
16 55faa0bc Stavros Sachtouris
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 55faa0bc Stavros Sachtouris
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 55faa0bc Stavros Sachtouris
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 55faa0bc Stavros Sachtouris
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 55faa0bc Stavros Sachtouris
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 55faa0bc Stavros Sachtouris
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 55faa0bc Stavros Sachtouris
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 55faa0bc Stavros Sachtouris
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 55faa0bc Stavros Sachtouris
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 55faa0bc Stavros Sachtouris
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 55faa0bc Stavros Sachtouris
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 55faa0bc Stavros Sachtouris
# POSSIBILITY OF SUCH DAMAGE.
28 55faa0bc Stavros Sachtouris
#
29 55faa0bc Stavros Sachtouris
# The views and conclusions contained in the software and
30 55faa0bc Stavros Sachtouris
# documentation are those of the authors and should not be
31 55faa0bc Stavros Sachtouris
# interpreted as representing official policies, either expressed
32 55faa0bc Stavros Sachtouris
# or implied, of GRNET S.A.
33 55faa0bc Stavros Sachtouris
34 55faa0bc Stavros Sachtouris
from kamaki.clients.compute import ComputeClient
35 55faa0bc Stavros Sachtouris
from kamaki.clients.utils import path4url
36 55faa0bc Stavros Sachtouris
import json
37 55faa0bc Stavros Sachtouris
38 55faa0bc Stavros Sachtouris
39 55faa0bc Stavros Sachtouris
class CycladesRestClient(ComputeClient):
40 76e7661e Stavros Sachtouris
    """Synnefo Cyclades REST API Client"""
41 55faa0bc Stavros Sachtouris
42 e51c7d5b Stavros Sachtouris
    def servers_stats_get(self, server_id, success=200, **kwargs):
43 e51c7d5b Stavros Sachtouris
        """GET base_url/servers/<server_id>/stats"""
44 e51c7d5b Stavros Sachtouris
        path = path4url('servers', server_id, 'stats')
45 e51c7d5b Stavros Sachtouris
        return self.get(path, success=success, **kwargs)
46 e51c7d5b Stavros Sachtouris
47 264a13f7 Stavros Sachtouris
    # def networks_get(
48 264a13f7 Stavros Sachtouris
    #         self,
49 264a13f7 Stavros Sachtouris
    #         network_id='',
50 264a13f7 Stavros Sachtouris
    #         command='',
51 264a13f7 Stavros Sachtouris
    #         success=(200, 203),
52 264a13f7 Stavros Sachtouris
    #         **kwargs):
53 264a13f7 Stavros Sachtouris
    #     """GET base_url/networks[/network_id][/command] request
54 264a13f7 Stavros Sachtouris
55 264a13f7 Stavros Sachtouris
    #     :param network_id: integer (str or int)
56 264a13f7 Stavros Sachtouris
57 264a13f7 Stavros Sachtouris
    #     :param command: (str) 'detail' or ''
58 264a13f7 Stavros Sachtouris
59 264a13f7 Stavros Sachtouris
    #     :param success: success code or list or tuple of accepted success
60 264a13f7 Stavros Sachtouris
    #         codes. if server response code is not in this list, a ClientError
61 264a13f7 Stavros Sachtouris
    #         raises
62 264a13f7 Stavros Sachtouris
63 264a13f7 Stavros Sachtouris
    #     :returns: request response
64 264a13f7 Stavros Sachtouris
    #     """
65 264a13f7 Stavros Sachtouris
    #     path = path4url('networks', network_id, command)
66 264a13f7 Stavros Sachtouris
    #     return self.get(path, success=success, **kwargs)
67 264a13f7 Stavros Sachtouris
68 264a13f7 Stavros Sachtouris
    # def networks_delete(
69 264a13f7 Stavros Sachtouris
    #         self,
70 264a13f7 Stavros Sachtouris
    #         network_id='',
71 264a13f7 Stavros Sachtouris
    #         command='',
72 264a13f7 Stavros Sachtouris
    #         success=204,
73 264a13f7 Stavros Sachtouris
    #         **kwargs):
74 264a13f7 Stavros Sachtouris
    #     """DEL ETE base_url/networks[/network_id][/command] request
75 264a13f7 Stavros Sachtouris
76 264a13f7 Stavros Sachtouris
    #     :param network_id: integer (str or int)
77 264a13f7 Stavros Sachtouris
78 264a13f7 Stavros Sachtouris
    #     :param command: (str) 'detail' or ''
79 264a13f7 Stavros Sachtouris
80 264a13f7 Stavros Sachtouris
    #     :param success: success code or list or tuple of accepted success
81 264a13f7 Stavros Sachtouris
    #         codes. if server response code is not in this list, a ClientError
82 264a13f7 Stavros Sachtouris
    #         raises
83 264a13f7 Stavros Sachtouris
84 264a13f7 Stavros Sachtouris
    #     :returns: request response
85 264a13f7 Stavros Sachtouris
    #     """
86 264a13f7 Stavros Sachtouris
    #     path = path4url('networks', network_id, command)
87 264a13f7 Stavros Sachtouris
    #     return self.delete(path, success=success, **kwargs)
88 264a13f7 Stavros Sachtouris
89 264a13f7 Stavros Sachtouris
    # def networks_post(
90 264a13f7 Stavros Sachtouris
    #         self,
91 264a13f7 Stavros Sachtouris
    #         network_id='',
92 264a13f7 Stavros Sachtouris
    #         command='',
93 264a13f7 Stavros Sachtouris
    #         json_data=None,
94 264a13f7 Stavros Sachtouris
    #         success=202,
95 264a13f7 Stavros Sachtouris
    #         **kwargs):
96 264a13f7 Stavros Sachtouris
    #     """POST base_url/servers[/server_id]/[command] request
97 264a13f7 Stavros Sachtouris
98 264a13f7 Stavros Sachtouris
    #     :param network_id: integer (str or int)
99 264a13f7 Stavros Sachtouris
100 264a13f7 Stavros Sachtouris
    #     :param command: (str) 'detail' or ''
101 264a13f7 Stavros Sachtouris
102 264a13f7 Stavros Sachtouris
    #     :param json_data: (dict) will be send as data
103 264a13f7 Stavros Sachtouris
104 264a13f7 Stavros Sachtouris
    #     :param success: success code or list or tuple of accepted success
105 264a13f7 Stavros Sachtouris
    #         codes. if server response code is not in this list, a ClientError
106 264a13f7 Stavros Sachtouris
    #         raises
107 264a13f7 Stavros Sachtouris
108 264a13f7 Stavros Sachtouris
    #     :returns: request response
109 264a13f7 Stavros Sachtouris
    #     """
110 264a13f7 Stavros Sachtouris
    #     data = json_data
111 264a13f7 Stavros Sachtouris
    #     if json_data is not None:
112 264a13f7 Stavros Sachtouris
    #         data = json.dumps(json_data)
113 264a13f7 Stavros Sachtouris
    #         self.set_header('Content-Type', 'application/json')
114 264a13f7 Stavros Sachtouris
    #         self.set_header('Content-Length', len(data))
115 264a13f7 Stavros Sachtouris
116 264a13f7 Stavros Sachtouris
    #     path = path4url('networks', network_id, command)
117 264a13f7 Stavros Sachtouris
    #     return self.post(path, data=data, success=success, **kwargs)
118 264a13f7 Stavros Sachtouris
119 264a13f7 Stavros Sachtouris
    # def networks_put(
120 264a13f7 Stavros Sachtouris
    #         self,
121 264a13f7 Stavros Sachtouris
    #         network_id='',
122 264a13f7 Stavros Sachtouris
    #         command='',
123 264a13f7 Stavros Sachtouris
    #         json_data=None,
124 264a13f7 Stavros Sachtouris
    #         success=204,
125 264a13f7 Stavros Sachtouris
    #         **kwargs):
126 264a13f7 Stavros Sachtouris
    #     """PUT base_url/servers[/server_id]/[command] request
127 264a13f7 Stavros Sachtouris
128 264a13f7 Stavros Sachtouris
    #     :param network_id: integer (str or int)
129 264a13f7 Stavros Sachtouris
130 264a13f7 Stavros Sachtouris
    #     :param command: (str) 'detail' or ''
131 264a13f7 Stavros Sachtouris
132 264a13f7 Stavros Sachtouris
    #     :param json_data: (dict) will be send as data
133 264a13f7 Stavros Sachtouris
134 264a13f7 Stavros Sachtouris
    #     :param success: success code or list or tuple of accepted success
135 264a13f7 Stavros Sachtouris
    #         codes. if server response code is not in this list, a ClientError
136 264a13f7 Stavros Sachtouris
    #         raises
137 264a13f7 Stavros Sachtouris
138 264a13f7 Stavros Sachtouris
    #     :returns: request response
139 264a13f7 Stavros Sachtouris
    #     """
140 264a13f7 Stavros Sachtouris
    #     data = json_data
141 264a13f7 Stavros Sachtouris
    #     if json_data is not None:
142 264a13f7 Stavros Sachtouris
    #         data = json.dumps(json_data)
143 264a13f7 Stavros Sachtouris
    #         self.set_header('Content-Type', 'application/json')
144 264a13f7 Stavros Sachtouris
    #         self.set_header('Content-Length', len(data))
145 264a13f7 Stavros Sachtouris
146 264a13f7 Stavros Sachtouris
    #     path = path4url('networks', network_id, command)
147 264a13f7 Stavros Sachtouris
    #     return self.put(path, data=data, success=success, **kwargs)