Add 'php/phpxmlrpc/' from commit 'cd5dbb4a511e7a616a61187a5de1a611a9748cbd'
[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', 'slice_id' and 'expires', and
11     (2) it 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         'expires': Slice.fields['expires'],
23         }
24
25     accepts = [
26         Auth(),
27         Mixed([Mixed(Slice.fields['slice_id'],
28                      Slice.fields['name'])],
29               Parameter(str,"name"),
30               Parameter(int,"slice_id"),
31               Filter(applicable_fields))
32         ]
33
34     returns = [applicable_fields]
35
36     def call(self, auth, slice_filter = None):
37
38         # Must query at least slice_id (see below)
39         return_fields = self.applicable_fields.keys()
40         # pass expires=0
41         slices = Slices(self.api, slice_filter, return_fields, 0)
42         return slices