Changed GetSlices to pass the additional information needed to the Slice table
[plcapi.git] / PLC / Methods / GetSlices.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.Persons import Person, Persons
8 from PLC.Sites import Site, Sites
9 from PLC.Slices import Slice, Slices
10
11 class GetSlices(Method):
12     """
13     Returns an array of structs containing details about slices. If
14     slice_filter is specified and is an array of slice identifiers or
15     slice names, or a struct of slice attributes, only slices matching
16     the filter will be returned. If return_fields is specified, only the
17     specified details will be returned.
18
19     Users may only query slices of which they are members. PIs may
20     query any of the slices at their sites. Admins and nodes may query
21     any slice. If a slice that cannot be queried is specified in
22     slice_filter, details about that slice will not be returned.
23     """
24
25     roles = ['admin', 'pi', 'user', 'node']
26
27     accepts = [
28         Auth(),
29         Mixed([Mixed(Slice.fields['slice_id'],
30                      Slice.fields['name'])],
31               Parameter(str,"name"),
32               Parameter(int,"slice_id"),
33               Filter(Slice.fields)),
34         Parameter([str], "List of fields to return", nullok = True)
35         ]
36
37     returns = [Slice.fields]
38
39     def call(self, auth, slice_filter = None, return_fields = None):
40         slices = Slices(self.api, self.caller, slice_filter, return_fields)
41         return slices