7a3386c5ca6b823943c80a6fa8c13ada0da9a5e0
[plcapi.git] / PLC / Methods / GetInterfaces.py
1 # $Id$
2 from PLC.Faults import *
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.Filter import Filter
6 from PLC.Interfaces import Interface, Interfaces
7 from PLC.Auth import Auth
8
9 class GetInterfaces(Method):
10     """
11     Returns an array of structs containing details about network
12     interfaces. If interfaces_filter is specified and is an array of
13     interface identifiers, or a struct of interface fields and
14     values, only interfaces matching the filter will be
15     returned.
16
17     If return_fields is given, only the specified details will be returned.
18     """
19
20     roles = ['admin', 'pi', 'user', 'tech', 'node', 'anonymous']
21
22     accepts = [
23         Auth(),
24         Mixed([Mixed(Interface.fields['interface_id'],
25                      Interface.fields['ip'])],
26               Parameter (int, "interface id"),
27               Parameter (str, "ip address"),
28               Filter(Interface.fields)),
29         Parameter([str], "List of fields to return", nullok = True)
30         ]
31
32     returns = [Interface.fields]
33     
34     def call(self, auth, interface_filter = None, return_fields = None):
35         return Interfaces(self.api, interface_filter, return_fields)