Merge from trunk
[plcapi.git] / trunk / PLC / Methods / DeleteConfFile.py
diff --git a/trunk/PLC/Methods/DeleteConfFile.py b/trunk/PLC/Methods/DeleteConfFile.py
new file mode 100644 (file)
index 0000000..f05ae43
--- /dev/null
@@ -0,0 +1,33 @@
+from PLC.Faults import *
+from PLC.Method import Method
+from PLC.Parameter import Parameter, Mixed
+from PLC.ConfFiles import ConfFile, ConfFiles
+from PLC.Auth import Auth
+
+class DeleteConfFile(Method):
+    """
+    Returns an array of structs containing details about node
+    configuration files. If conf_file_ids is specified, only the
+    specified configuration files will be queried.
+    """
+
+    roles = ['admin']
+
+    accepts = [
+        Auth(),
+        ConfFile.fields['conf_file_id']
+        ]
+
+    returns = Parameter(int, '1 if successful')
+    
+
+    def call(self, auth, conf_file_id):
+        conf_files = ConfFiles(self.api, [conf_file_id])
+        if not conf_files:
+            raise PLCInvalidArgument, "No such configuration file"
+
+        conf_file = conf_files[0]
+        conf_file.delete()
+       self.event_objects = {'ConfFile': [conf_file['conf_file_id']]}
+
+        return 1