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