from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
from PLC.Auth import Auth
from PLC.Slices import Slice, Slices
class GetSlices(Method):
"""
- Return an array of structs containing details about slices. If
- slice_id_or_name_list is specified, only the specified slices will
- be queried.
+ Returns an array of structs containing details about slices. If
+ slice_filter is specified and is an array of slice identifiers or
+ slice names, or a struct of slice attributes, only slices matching
+ the filter will be returned.
Users may only query slices of which they are members. PIs may
query any of the slices at their sites. Admins may query any
accepts = [
Auth(),
- [Mixed(Slice.fields['slice_id'],
- Slice.fields['name'])]
+ Mixed([Mixed(Slice.fields['slice_id'],
+ Slice.fields['name'])],
+ Filter(Slice.fields))
]
returns = [Slice.fields]
- def call(self, auth, slice_id_or_name_list = None):
+ def call(self, auth, slice_filter = None):
# If we are not admin, make sure to return only viewable
# slices.
if 'admin' not in self.caller['roles']:
if not valid_slice_ids:
return []
- if not slice_id_or_name_list:
- slice_id_or_name_list = valid_slice_ids
+ if slice_filter is None:
+ slice_filter = valid_slice_ids
- slices = Slices(self.api, slice_id_or_name_list).values()
+ slices = Slices(self.api, slice_filter).values()
# Filter out slices that are not viewable
if 'admin' not in self.caller['roles']: