|
| 1 | +from pubnub.enums import PNOperationType, HttpMethod |
| 2 | +from pubnub.endpoints.endpoint import Endpoint |
| 3 | +from pubnub.models.consumer.v3.access_manager import PNRevokeTokenResult |
| 4 | +from pubnub import utils |
| 5 | + |
| 6 | + |
| 7 | +class RevokeToken(Endpoint): |
| 8 | + REVOKE_TOKEN_PATH = "/v3/pam/%s/grant/%s" |
| 9 | + |
| 10 | + def __init__(self, pubnub, token): |
| 11 | + Endpoint.__init__(self, pubnub) |
| 12 | + self.token = token |
| 13 | + |
| 14 | + def validate_params(self): |
| 15 | + self.validate_subscribe_key() |
| 16 | + self.validate_secret_key() |
| 17 | + |
| 18 | + def create_response(self, envelope): |
| 19 | + return PNRevokeTokenResult(envelope) |
| 20 | + |
| 21 | + def is_auth_required(self): |
| 22 | + return False |
| 23 | + |
| 24 | + def request_timeout(self): |
| 25 | + return self.pubnub.config.non_subscribe_request_timeout |
| 26 | + |
| 27 | + def connect_timeout(self): |
| 28 | + return self.pubnub.config.connect_timeout |
| 29 | + |
| 30 | + def http_method(self): |
| 31 | + return HttpMethod.DELETE |
| 32 | + |
| 33 | + def custom_params(self): |
| 34 | + return {} |
| 35 | + |
| 36 | + def build_path(self): |
| 37 | + return RevokeToken.REVOKE_TOKEN_PATH % (self.pubnub.config.subscribe_key, utils.url_encode(self.token)) |
| 38 | + |
| 39 | + def operation_type(self): |
| 40 | + return PNOperationType.PNAccessManagerRevokeToken |
| 41 | + |
| 42 | + def name(self): |
| 43 | + return "RevokeToken" |
0 commit comments