| OLD | NEW |
| 1 """Channel notifications support. | 1 """Channel notifications support. |
| 2 | 2 |
| 3 Classes and functions to support channel subscriptions and notifications | 3 Classes and functions to support channel subscriptions and notifications |
| 4 on those channels. | 4 on those channels. |
| 5 | 5 |
| 6 Notes: | 6 Notes: |
| 7 - This code is based on experimental APIs and is subject to change. | 7 - This code is based on experimental APIs and is subject to change. |
| 8 - Notification does not do deduplication of notification ids, that's up to | 8 - Notification does not do deduplication of notification ids, that's up to |
| 9 the receiver. | 9 the receiver. |
| 10 - Storing the Channel between calls is up to the caller. | 10 - Storing the Channel between calls is up to the caller. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 Example of unsubscribing. | 54 Example of unsubscribing. |
| 55 | 55 |
| 56 service.channels().stop(channel.body()) | 56 service.channels().stop(channel.body()) |
| 57 """ | 57 """ |
| 58 | 58 |
| 59 import datetime | 59 import datetime |
| 60 import uuid | 60 import uuid |
| 61 | 61 |
| 62 from googleapiclient import errors | 62 from googleapiclient import errors |
| 63 from third_party.oauth2client import util | 63 from ...oauth2client import util |
| 64 | 64 |
| 65 | 65 |
| 66 # The unix time epoch starts at midnight 1970. | 66 # The unix time epoch starts at midnight 1970. |
| 67 EPOCH = datetime.datetime.utcfromtimestamp(0) | 67 EPOCH = datetime.datetime.utcfromtimestamp(0) |
| 68 | 68 |
| 69 # Map the names of the parameters in the JSON channel description to | 69 # Map the names of the parameters in the JSON channel description to |
| 70 # the parameter names we use in the Channel class. | 70 # the parameter names we use in the Channel class. |
| 71 CHANNEL_PARAMS = { | 71 CHANNEL_PARAMS = { |
| 72 'address': 'address', | 72 'address': 'address', |
| 73 'id': 'id', | 73 'id': 'id', |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 delta = expiration - EPOCH | 276 delta = expiration - EPOCH |
| 277 expiration_ms = delta.microseconds/1000 + ( | 277 expiration_ms = delta.microseconds/1000 + ( |
| 278 delta.seconds + delta.days*24*3600)*1000 | 278 delta.seconds + delta.days*24*3600)*1000 |
| 279 if expiration_ms < 0: | 279 if expiration_ms < 0: |
| 280 expiration_ms = 0 | 280 expiration_ms = 0 |
| 281 | 281 |
| 282 return Channel('web_hook', str(uuid.uuid4()), | 282 return Channel('web_hook', str(uuid.uuid4()), |
| 283 token, url, expiration=expiration_ms, | 283 token, url, expiration=expiration_ms, |
| 284 params=params) | 284 params=params) |
| 285 | 285 |
| OLD | NEW |