- Change .py files to use 4-space indents and no hard tab characters.
[plcapi.git] / PLC / Methods / DeleteKeyType.py
1 # $Id$
2 # $URL$
3 from PLC.Faults import *
4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.KeyTypes import KeyType, KeyTypes
7 from PLC.Auth import Auth
8
9 class DeleteKeyType(Method):
10     """
11     Deletes a key type.
12
13     WARNING: This will cause the deletion of all keys of this type.
14
15     Returns 1 if successful, faults otherwise.
16     """
17
18     roles = ['admin']
19
20     accepts = [
21         Auth(),
22         KeyType.fields['key_type']
23         ]
24
25     returns = Parameter(int, '1 if successful')
26
27
28     def call(self, auth, name):
29         key_types = KeyTypes(self.api, [name])
30         if not key_types:
31             raise PLCInvalidArgument, "No such key type"
32         key_type = key_types[0]
33
34         key_type.delete()
35
36         return 1