get rid of svn keywords once and for good
[plcapi.git] / PLC / Methods / ResolveSlices.py
1 from PLC.Method import Method
2 from PLC.Parameter import Parameter, Mixed
3 from PLC.Filter import Filter
4 from PLC.Auth import Auth
5 from PLC.Slices import Slice, Slices
6
7 class ResolveSlices(Method):
8     """
9     This method is similar to GetSlices, except that (1) the returned
10     columns are restricted to 'name' and 'slice_id', and (2) it
11     returns expired slices too. This method is designed to help
12     third-party software solve slice names from their slice_id
13     (e.g. PlanetFlow Central). For this reason it is accessible with
14     anonymous authentication (among others).
15     """
16
17     roles = ['admin', 'pi', 'user', 'tech', 'anonymous' ]
18
19     applicable_fields = {
20         'slice_id' : Slice.fields['slice_id'],
21         'name' : Slice.fields['name'],
22         }
23
24     accepts = [
25         Auth(),
26         Mixed([Mixed(Slice.fields['slice_id'],
27                      Slice.fields['name'])],
28               Parameter(str,"name"),
29               Parameter(int,"slice_id"),
30               Filter(applicable_fields))
31         ]
32
33     returns = [applicable_fields]
34
35     def call(self, auth, slice_filter = None):
36
37         # Must query at least slice_id (see below)
38         return_fields = self.applicable_fields.keys()
39         # pass expires=0
40         slices = Slices(self.api, slice_filter, return_fields, 0)
41         return slices