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