Merge from trunk
[plcapi.git] / trunk / PLC / Methods / GetNetworkTypes.py
diff --git a/trunk/PLC/Methods/GetNetworkTypes.py b/trunk/PLC/Methods/GetNetworkTypes.py
new file mode 100644 (file)
index 0000000..dbddd9f
--- /dev/null
@@ -0,0 +1,22 @@
+from PLC.Faults import *
+from PLC.Method import Method
+from PLC.Parameter import Parameter, Mixed
+from PLC.NetworkTypes import NetworkType, NetworkTypes
+from PLC.Auth import Auth
+
+class GetNetworkTypes(Method):
+    """
+    Returns a list of all valid network types.
+    """
+
+    roles = ['admin', 'pi', 'user', 'tech', 'node']
+
+    accepts = [
+        Auth()
+        ]
+
+    returns = [NetworkType.fields['type']]
+
+
+    def call(self, auth):
+        return [network_type['type'] for network_type in NetworkTypes(self.api)]