blob: 77e5f1ade2b1b592fc4299f8508a68f2bfbb52f9 [file] [log] [blame]
Oleksiy Petrenkoe2c8da22018-03-30 18:27:58 +03001# Copyright 2018 Mirantis Inc
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16import urllib
17
18from manilang.common import send, MANILA_HEADER
19
20
21@send('get', MANILA_HEADER)
22def list_shares(**kwargs):
23 url = '/shares?{}'.format(urllib.urlencode(kwargs))
24 return url, None
25
26
27@send('get', MANILA_HEADER)
28def list_shares_detailed(**kwargs):
29
30 url = '/shares/detail?{}'.format(urllib.urlencode(kwargs))
31 return url, None
32
33
34@send('get', MANILA_HEADER)
35def get_share_details(share_id, **kwargs):
36 url = '/shares/{}'.format(share_id)
37 return url, None
38
39
40@send('post', MANILA_HEADER)
41def create_share(share_proto, size, **kwargs):
42 url = '/shares'
43 json = {
44 'share': {
45 'share_proto': share_proto,
46 'size': size,
47 },
48 }
49 json['share'].update(kwargs)
50 return url, json
51
52
53@send('post', MANILA_HEADER)
54def manage_share(protocol, export_path, service_host, **kwargs):
55 url = '/shares/manage'
56 json = {
57 'share': {
58 'protocol': protocol,
59 'export_path': export_path,
60 'service_host': service_host,
61 }
62 }
63 json['share'].update(kwargs)
64 return url, json
65
66
67@send('put', MANILA_HEADER)
68def update_share(share_id, **kwargs):
69 url = '/shares/{}'.format(share_id)
70 json = {
71 'share': kwargs,
72 }
73 return url, json
74
75
76@send('delete', MANILA_HEADER)
77def delete_share(share_id, **kwargs):
78 url = '/shares/{}'.format(share_id)
79 return url, None