8db20a8cf1faca33b0ba97dd2065b38c3f7f0ad4
[plcapi.git] / PLC / Methods / SliceListNames.py
1 # $Id$
2 # $URL$
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.Filter import Filter
6 from PLC.Auth import Auth
7 from PLC.Slices import Slice, Slices
8 from PLC.Methods.GetSlices import GetSlices
9
10 class SliceListNames(GetSlices):
11     """
12     Deprecated. Can be implemented with GetSlices.
13
14     List the names of registered slices.
15
16     Users may only query slices of which they are members. PIs may
17     query any of the slices at their sites. Admins may query any
18     slice. If a slice that cannot be queried is specified in
19     slice_filter, details about that slice will not be returned.
20     """
21
22     status = "deprecated"
23
24     roles = ['admin', 'pi', 'user']
25
26     accepts = [
27         Auth(),
28         Parameter(str, "Slice prefix", nullok = True)
29         ]
30
31     returns = [Slice.fields['name']]
32
33
34     def call(self, auth, prefix=None):
35
36         slice_filter = None
37         if prefix:
38             slice_filter = {'name': prefix+'*'}
39
40         slices = GetSlices.call(self, auth, slice_filter)
41
42         if not slices:
43             raise PLCInvalidArgument, "No such slice"
44
45         slice_names = [slice['name'] for slice in slices]
46
47         return slice_names