svn keywords
[plcapi.git] / PLC / Methods / DeleteTagType.py
1 # $Id$
2 # $URL$
3 #
4 # Thierry Parmentelat - INRIA
5 #
6 # $Revision: 9423 $
7 #
8 from PLC.Faults import *
9 from PLC.Method import Method
10 from PLC.Parameter import Parameter, Mixed
11 from PLC.TagTypes import TagType, TagTypes
12 from PLC.Auth import Auth
13
14 class DeleteTagType(Method):
15     """
16     Deletes the specified node tag type.
17
18     Returns 1 if successful, faults otherwise.
19     """
20
21     roles = ['admin']
22
23     accepts = [
24         Auth(),
25         Mixed(TagType.fields['tag_type_id'],
26               TagType.fields['tagname']),
27         ]
28
29     returns = Parameter(int, '1 if successful')
30
31
32     def call(self, auth, tag_type_id_or_name):
33         tag_types = TagTypes(self.api, [tag_type_id_or_name])
34         if not tag_types:
35             raise PLCInvalidArgument, "No such node tag type"
36         tag_type = tag_types[0]
37
38         tag_type.delete()
39         self.object_ids = [tag_type['tag_type_id']]
40
41         return 1