group db-related stuff in sfa/storage
[sfa.git] / sfa / methods / RedeemTicket.py
1 from sfa.util.method import Method
2
3 from sfa.storage.parameter import Parameter, Mixed
4
5 class RedeemTicket(Method):
6     """
7
8     @param cred credential string specifying the rights of the caller
9     @param ticket 
10     @return 1 is successful, faults otherwise  
11     """
12
13     interfaces = ['component']
14     
15     accepts = [
16         Parameter(str, "Ticket  string representation of SFA ticket"),
17         Mixed(Parameter(str, "Credential string"),
18               Parameter(type([str]), "List of credentials")),
19         ]
20
21     returns = [Parameter(int, "1 if successful")]
22     
23     def call(self, ticket, creds):
24         valid_creds = self.api.auth.checkCredentials(cred, 'redeemticket')
25         self.api.auth.check_ticket(ticket)
26
27         # send the call to the right manager
28         self.api.manager.redeem_ticket(self.api, ticket) 
29         return 1