only log errors if logging is enabled
[plcapi.git] / PLC / Methods / DeleteLinkType.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.LinkTypes import LinkType, LinkTypes
10 from PLC.Auth import Auth
11
12 class DeleteLinkType(Method):
13     """
14     Deletes the specified ilink type.
15
16     Returns 1 if successful, faults otherwise.
17     """
18
19     roles = ['admin']
20
21     accepts = [
22         Auth(),
23         Mixed(LinkType.fields['link_type_id'],
24               LinkType.fields['name']),
25         ]
26
27     returns = Parameter(int, '1 if successful')
28
29
30     def call(self, auth, link_type_id_or_name):
31         link_types = LinkTypes(self.api, [link_type_id_or_name])
32         if not link_types:
33             raise PLCInvalidArgument, "No such ilink type"
34         link_type = link_types[0]
35
36         link_type.delete()
37         self.object_ids = [link_type['link_type_id']]
38
39         return 1