root / kamaki / clients / network / rest_api.py @ 89a1c636
History | View | Annotate | Download (3.9 kB)
1 | c6ebe715 | Stavros Sachtouris | # Copyright 2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | c6ebe715 | Stavros Sachtouris | #
|
3 | c6ebe715 | Stavros Sachtouris | # Redistribution and use in source and binary forms, with or
|
4 | c6ebe715 | Stavros Sachtouris | # without modification, are permitted provided that the following
|
5 | c6ebe715 | Stavros Sachtouris | # conditions are met:
|
6 | c6ebe715 | Stavros Sachtouris | #
|
7 | c6ebe715 | Stavros Sachtouris | # 1. Redistributions of source code must retain the above
|
8 | c6ebe715 | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
9 | c6ebe715 | Stavros Sachtouris | # disclaimer.
|
10 | c6ebe715 | Stavros Sachtouris | #
|
11 | c6ebe715 | Stavros Sachtouris | # 2. Redistributions in binary form must reproduce the above
|
12 | c6ebe715 | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
13 | c6ebe715 | Stavros Sachtouris | # disclaimer in the documentation and/or other materials
|
14 | c6ebe715 | Stavros Sachtouris | # provided with the distribution.
|
15 | c6ebe715 | Stavros Sachtouris | #
|
16 | c6ebe715 | Stavros Sachtouris | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | c6ebe715 | Stavros Sachtouris | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | c6ebe715 | Stavros Sachtouris | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | c6ebe715 | Stavros Sachtouris | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | c6ebe715 | Stavros Sachtouris | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | c6ebe715 | Stavros Sachtouris | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | c6ebe715 | Stavros Sachtouris | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | c6ebe715 | Stavros Sachtouris | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | c6ebe715 | Stavros Sachtouris | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | c6ebe715 | Stavros Sachtouris | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | c6ebe715 | Stavros Sachtouris | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | c6ebe715 | Stavros Sachtouris | # POSSIBILITY OF SUCH DAMAGE.
|
28 | c6ebe715 | Stavros Sachtouris | #
|
29 | c6ebe715 | Stavros Sachtouris | # The views and conclusions contained in the software and
|
30 | c6ebe715 | Stavros Sachtouris | # documentation are those of the authors and should not be
|
31 | c6ebe715 | Stavros Sachtouris | # interpreted as representing official policies, either expressed
|
32 | c6ebe715 | Stavros Sachtouris | # or implied, of GRNET S.A.
|
33 | c6ebe715 | Stavros Sachtouris | |
34 | 963bd664 | Stavros Sachtouris | from kamaki.clients import Client |
35 | c6ebe715 | Stavros Sachtouris | from kamaki.clients.utils import path4url |
36 | c6ebe715 | Stavros Sachtouris | |
37 | c6ebe715 | Stavros Sachtouris | |
38 | 5c433331 | Stavros Sachtouris | class NetworkRestClient(Client): |
39 | c6ebe715 | Stavros Sachtouris | |
40 | c6ebe715 | Stavros Sachtouris | def networks_get(self, network_id=None, **kwargs): |
41 | 963bd664 | Stavros Sachtouris | if network_id:
|
42 | 963bd664 | Stavros Sachtouris | return self.get(path4url('networks', network_id), **kwargs) |
43 | 963bd664 | Stavros Sachtouris | return self.get(path4url('networks'), **kwargs) |
44 | c6ebe715 | Stavros Sachtouris | |
45 | ba1ab65d | Stavros Sachtouris | def networks_post(self, json_data, **kwargs): |
46 | 56f5c6fc | Stavros Sachtouris | return self.post(path4url('networks'), json=json_data, **kwargs) |
47 | c6ebe715 | Stavros Sachtouris | |
48 | ba1ab65d | Stavros Sachtouris | def networks_put(self, network_id, json_data, **kwargs): |
49 | c6ebe715 | Stavros Sachtouris | return self.put( |
50 | 56f5c6fc | Stavros Sachtouris | path4url('networks', network_id), json=json_data, **kwargs)
|
51 | c6ebe715 | Stavros Sachtouris | |
52 | c6ebe715 | Stavros Sachtouris | def networks_delete(self, network_id, **kwargs): |
53 | c6ebe715 | Stavros Sachtouris | return self.delete(path4url('networks', network_id), **kwargs) |
54 | c6ebe715 | Stavros Sachtouris | |
55 | 963bd664 | Stavros Sachtouris | def subnets_get(self, subnet_id=None, **kwargs): |
56 | c6ebe715 | Stavros Sachtouris | if subnet_id:
|
57 | c6ebe715 | Stavros Sachtouris | return self.get(path4url('subnets', subnet_id), **kwargs) |
58 | 963bd664 | Stavros Sachtouris | return self.get(path4url('subnets'), **kwargs) |
59 | c6ebe715 | Stavros Sachtouris | |
60 | ba1ab65d | Stavros Sachtouris | def subnets_post(self, json_data, **kwargs): |
61 | 56f5c6fc | Stavros Sachtouris | return self.post(path4url('subnets'), json=json_data, **kwargs) |
62 | c6ebe715 | Stavros Sachtouris | |
63 | c6ebe715 | Stavros Sachtouris | def subnets_put(self, subnet_id, **kwargs): |
64 | c6ebe715 | Stavros Sachtouris | return self.put(path4url('subnets', subnet_id), **kwargs) |
65 | c6ebe715 | Stavros Sachtouris | |
66 | c6ebe715 | Stavros Sachtouris | def subnets_delete(self, subnet_id, **kwargs): |
67 | c6ebe715 | Stavros Sachtouris | return self.delete(path4url('subnets', subnet_id), **kwargs) |
68 | c6ebe715 | Stavros Sachtouris | |
69 | c6ebe715 | Stavros Sachtouris | def ports_get(self, port_id=None, **kwargs): |
70 | 963bd664 | Stavros Sachtouris | if port_id:
|
71 | 963bd664 | Stavros Sachtouris | return self.get(path4url('ports', port_id), **kwargs) |
72 | 963bd664 | Stavros Sachtouris | return self.get(path4url('ports'), **kwargs) |
73 | c6ebe715 | Stavros Sachtouris | |
74 | 447365fe | Stavros Sachtouris | def ports_post(self, json_data=None, **kwargs): |
75 | 56f5c6fc | Stavros Sachtouris | return self.post(path4url('ports'), json=json_data, **kwargs) |
76 | c6ebe715 | Stavros Sachtouris | |
77 | 447365fe | Stavros Sachtouris | def ports_put(self, port_id, json_data=None, **kwargs): |
78 | 56f5c6fc | Stavros Sachtouris | return self.put(path4url('ports', port_id), json=json_data, **kwargs) |
79 | c6ebe715 | Stavros Sachtouris | |
80 | c6ebe715 | Stavros Sachtouris | def ports_delete(self, port_id, **kwargs): |
81 | c6ebe715 | Stavros Sachtouris | return self.delete(path4url('ports', port_id), **kwargs) |
82 | 8fd99602 | Stavros Sachtouris | |
83 | 8fd99602 | Stavros Sachtouris | # floatingips (L3) extentions
|
84 | 8fd99602 | Stavros Sachtouris | |
85 | 8fd99602 | Stavros Sachtouris | def floatingips_get(self, floatingip_id=None, **kwargs): |
86 | 8fd99602 | Stavros Sachtouris | return self.get(path4url('floatingips', floatingip_id or ''), **kwargs) |
87 | 8fd99602 | Stavros Sachtouris | |
88 | 8fd99602 | Stavros Sachtouris | def floatingips_post(self, json_data, **kwargs): |
89 | 8fd99602 | Stavros Sachtouris | return self.post(path4url('floatingips'), json=json_data, **kwargs) |
90 | 8fd99602 | Stavros Sachtouris | |
91 | 8fd99602 | Stavros Sachtouris | def floatingips_put(self, floatingip_id, json_data, **kwargs): |
92 | 8fd99602 | Stavros Sachtouris | return self.put( |
93 | 8fd99602 | Stavros Sachtouris | path4url('floatingips', floatingip_id), json=json_data, **kwargs)
|
94 | 8fd99602 | Stavros Sachtouris | |
95 | 8fd99602 | Stavros Sachtouris | def floatingips_delete(self, floatingip_id, **kwargs): |
96 | 8fd99602 | Stavros Sachtouris | return self.delete(path4url('floatingips', floatingip_id), **kwargs) |