aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevendra2014-06-24 10:57:35 +0530
committerDevendra2014-06-24 10:57:35 +0530
commit9217c4f7fdfb36cc67121d1ab173a1e2305c7a35 (patch)
tree9f4c1c08abe1455c1c92e5549e892f5603f8dfba
parentf04a318d1825d28f24802ea0a5ecc27ea04c4a38 (diff)
downloadpubnub-python-9217c4f7fdfb36cc67121d1ab173a1e2305c7a35.tar.bz2
[#73754750 develop] adding examples for grant, revoke, audit
-rw-r--r--python-tornado/README.md32
-rw-r--r--python-tornado/examples/audit.py31
-rw-r--r--python-tornado/examples/grant.py31
-rw-r--r--python-tornado/examples/revoke.py31
-rw-r--r--python-twisted/README.md32
-rw-r--r--python-twisted/examples/audit.py31
-rw-r--r--python-twisted/examples/grant.py31
-rw-r--r--python-twisted/examples/revoke.py31
-rw-r--r--python/README.md52
-rw-r--r--python/examples/audit.py35
-rw-r--r--python/examples/grant.py35
-rw-r--r--python/examples/revoke.py35
12 files changed, 407 insertions, 0 deletions
diff --git a/python-tornado/README.md b/python-tornado/README.md
index 53aad32..59e79b7 100644
--- a/python-tornado/README.md
+++ b/python-tornado/README.md
@@ -97,6 +97,38 @@ pubnub.presence(channel, callback=callback, error=callback)
pubnub.unsubscribe(channel='hello_world')
```
+#### Grant Example
+```
+authkey = "abcd"
+
+def callback(message):
+ print(message)
+
+pubnub.grant(channel, authkey, True, True, callback=callback, error=callback)
+
+```
+
+#### Audit Example
+```
+authkey = "abcd"
+
+def callback(message):
+ print(message)
+
+pubnub.audit(channel, authkey, callback=callback, error=callback)
+```
+
+#### Revoke Example
+```
+authkey = "abcd"
+
+def callback(message):
+ print(message)
+
+pubnub.revoke(channel, authkey, callback=callback, error=callback)
+```
+
+
#### IO Event Loop start
```
pubnub.start()
diff --git a/python-tornado/examples/audit.py b/python-tornado/examples/audit.py
new file mode 100644
index 0000000..77d189b
--- /dev/null
+++ b/python-tornado/examples/audit.py
@@ -0,0 +1,31 @@
+## www.pubnub.com - PubNub Real-time push service in the cloud.
+# coding=utf8
+
+## PubNub Real-time Push APIs and Notifications Framework
+## Copyright (c) 2010 Stephen Blum
+## http://www.pubnub.com/
+
+
+import sys
+from Pubnub import PubnubTornado as Pubnub
+
+publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
+subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
+secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
+cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
+ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False
+
+## -----------------------------------------------------------------------
+## Initiate Pubnub State
+## -----------------------------------------------------------------------
+pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
+ secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
+channel = 'hello_world'
+authkey = "abcd"
+
+def callback(message):
+ print(message)
+
+pubnub.audit(channel, authkey, callback=callback, error=callback)
+
+pubnub.start()
diff --git a/python-tornado/examples/grant.py b/python-tornado/examples/grant.py
new file mode 100644
index 0000000..daf7434
--- /dev/null
+++ b/python-tornado/examples/grant.py
@@ -0,0 +1,31 @@
+## www.pubnub.com - PubNub Real-time push service in the cloud.
+# coding=utf8
+
+## PubNub Real-time Push APIs and Notifications Framework
+## Copyright (c) 2010 Stephen Blum
+## http://www.pubnub.com/
+
+
+import sys
+from Pubnub import PubnubTornado as Pubnub
+
+publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
+subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
+secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
+cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
+ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False
+
+## -----------------------------------------------------------------------
+## Initiate Pubnub State
+## -----------------------------------------------------------------------
+pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
+ secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
+channel = 'hello_world'
+authkey = "abcd"
+
+def callback(message):
+ print(message)
+
+pubnub.grant(channel, authkey, True, True, callback=callback, error=callback)
+
+pubnub.start()
diff --git a/python-tornado/examples/revoke.py b/python-tornado/examples/revoke.py
new file mode 100644
index 0000000..1e4487e
--- /dev/null
+++ b/python-tornado/examples/revoke.py
@@ -0,0 +1,31 @@
+## www.pubnub.com - PubNub Real-time push service in the cloud.
+# coding=utf8
+
+## PubNub Real-time Push APIs and Notifications Framework
+## Copyright (c) 2010 Stephen Blum
+## http://www.pubnub.com/
+
+
+import sys
+from Pubnub import PubnubTornado as Pubnub
+
+publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
+subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
+secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
+cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
+ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False
+
+## -----------------------------------------------------------------------
+## Initiate Pubnub State
+## -----------------------------------------------------------------------
+pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
+ secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
+channel = 'hello_world'
+authkey = "abcd"
+
+def callback(message):
+ print(message)
+
+pubnub.revoke(channel, authkey, callback=callback, error=callback)
+
+pubnub.start()
diff --git a/python-twisted/README.md b/python-twisted/README.md
index ea4173c..c74fb0d 100644
--- a/python-twisted/README.md
+++ b/python-twisted/README.md
@@ -97,6 +97,38 @@ pubnub.presence(channel, callback=callback, error=callback)
pubnub.unsubscribe(channel='hello_world')
```
+#### Grant Example
+```
+authkey = "abcd"
+
+def callback(message):
+ print(message)
+
+pubnub.grant(channel, authkey, True, True, callback=callback, error=callback)
+
+```
+
+#### Audit Example
+```
+authkey = "abcd"
+
+def callback(message):
+ print(message)
+
+pubnub.audit(channel, authkey, callback=callback, error=callback)
+```
+
+#### Revoke Example
+```
+authkey = "abcd"
+
+def callback(message):
+ print(message)
+
+pubnub.revoke(channel, authkey, callback=callback, error=callback)
+```
+
+
#### IO Event Loop start
```
pubnub.start()
diff --git a/python-twisted/examples/audit.py b/python-twisted/examples/audit.py
new file mode 100644
index 0000000..b99a8a9
--- /dev/null
+++ b/python-twisted/examples/audit.py
@@ -0,0 +1,31 @@
+## www.pubnub.com - PubNub Real-time push service in the cloud.
+# coding=utf8
+
+## PubNub Real-time Push APIs and Notifications Framework
+## Copyright (c) 2010 Stephen Blum
+## http://www.pubnub.com/
+
+
+import sys
+from Pubnub import PubnubTwisted as Pubnub
+
+publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
+subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
+secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
+cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
+ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False
+
+## -----------------------------------------------------------------------
+## Initiate Pubnub State
+## -----------------------------------------------------------------------
+pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
+ secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
+channel = 'hello_world'
+authkey = "abcd"
+
+def callback(message):
+ print(message)
+
+pubnub.audit(channel, authkey, callback=callback, error=callback)
+
+pubnub.start()
diff --git a/python-twisted/examples/grant.py b/python-twisted/examples/grant.py
new file mode 100644
index 0000000..053c1f9
--- /dev/null
+++ b/python-twisted/examples/grant.py
@@ -0,0 +1,31 @@
+## www.pubnub.com - PubNub Real-time push service in the cloud.
+# coding=utf8
+
+## PubNub Real-time Push APIs and Notifications Framework
+## Copyright (c) 2010 Stephen Blum
+## http://www.pubnub.com/
+
+
+import sys
+from Pubnub import PubnubTwisted as Pubnub
+
+publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
+subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
+secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
+cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
+ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False
+
+## -----------------------------------------------------------------------
+## Initiate Pubnub State
+## -----------------------------------------------------------------------
+pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
+ secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
+channel = 'hello_world'
+authkey = "abcd"
+
+def callback(message):
+ print(message)
+
+pubnub.grant(channel, authkey, True, True, callback=callback, error=callback)
+
+pubnub.start()
diff --git a/python-twisted/examples/revoke.py b/python-twisted/examples/revoke.py
new file mode 100644
index 0000000..fab0497
--- /dev/null
+++ b/python-twisted/examples/revoke.py
@@ -0,0 +1,31 @@
+## www.pubnub.com - PubNub Real-time push service in the cloud.
+# coding=utf8
+
+## PubNub Real-time Push APIs and Notifications Framework
+## Copyright (c) 2010 Stephen Blum
+## http://www.pubnub.com/
+
+
+import sys
+from Pubnub import PubnubTwisted as Pubnub
+
+publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
+subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
+secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
+cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
+ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False
+
+## -----------------------------------------------------------------------
+## Initiate Pubnub State
+## -----------------------------------------------------------------------
+pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
+ secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
+channel = 'hello_world'
+authkey = "abcd"
+
+def callback(message):
+ print(message)
+
+pubnub.revoke(channel, authkey, callback=callback, error=callback)
+
+pubnub.start()
diff --git a/python/README.md b/python/README.md
index 0877535..63548ad 100644
--- a/python/README.md
+++ b/python/README.md
@@ -140,4 +140,56 @@ def callback(message):
pubnub.history(channel, count=2, callback=callback, error=callback)
```
+
+#### GRANT
+
+```
+authkey = "abcd"
+
+# Synchronous usage
+print pubnub.grant(channel, authkey, True, True)
+
+# Asynchronous usage
+
+
+def callback(message):
+ print(message)
+
+pubnub.grant(channel, authkey, True, True, callback=callback, error=callback)
+```
+
+#### AUDIT
+
+```
+authkey = "abcd"
+
+# Synchronous usage
+print pubnub.audit(channel, authkey)
+
+# Asynchronous usage
+
+
+def callback(message):
+ print(message)
+
+pubnub.audit(channel, authkey, callback=callback, error=callback)
+```
+
+#### REVOKE
+
+```
+authkey = "abcd"
+
+# Synchronous usage
+print pubnub.revoke(channel, authkey)
+
+# Asynchronous usage
+
+
+def callback(message):
+ print(message)
+
+pubnub.revoke(channel, authkey, callback=callback, error=callback)
+```
+
## Contact support@pubnub.com for all questions
diff --git a/python/examples/audit.py b/python/examples/audit.py
new file mode 100644
index 0000000..ebf31af
--- /dev/null
+++ b/python/examples/audit.py
@@ -0,0 +1,35 @@
+## www.pubnub.com - PubNub Real-time push service in the cloud.
+# coding=utf8
+
+## PubNub Real-time Push APIs and Notifications Framework
+## Copyright (c) 2010 Stephen Blum
+## http://www.pubnub.com/
+
+
+import sys
+from Pubnub import Pubnub
+
+publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
+subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
+secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
+cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
+ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False
+
+## -----------------------------------------------------------------------
+## Initiate Pubnub State
+## -----------------------------------------------------------------------
+pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
+ secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
+channel = 'hello_world'
+authkey = "abcd"
+
+# Synchronous usage
+print pubnub.audit(channel, authkey)
+
+# Asynchronous usage
+
+
+def callback(message):
+ print(message)
+
+pubnub.audit(channel, authkey, callback=callback, error=callback)
diff --git a/python/examples/grant.py b/python/examples/grant.py
new file mode 100644
index 0000000..af9352e
--- /dev/null
+++ b/python/examples/grant.py
@@ -0,0 +1,35 @@
+## www.pubnub.com - PubNub Real-time push service in the cloud.
+# coding=utf8
+
+## PubNub Real-time Push APIs and Notifications Framework
+## Copyright (c) 2010 Stephen Blum
+## http://www.pubnub.com/
+
+
+import sys
+from Pubnub import Pubnub
+
+publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
+subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
+secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
+cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
+ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False
+
+## -----------------------------------------------------------------------
+## Initiate Pubnub State
+## -----------------------------------------------------------------------
+pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
+ secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
+channel = 'hello_world'
+authkey = "abcd"
+
+# Synchronous usage
+print pubnub.grant(channel, authkey, True, True)
+
+# Asynchronous usage
+
+
+def callback(message):
+ print(message)
+
+pubnub.grant(channel, authkey, True, True, callback=callback, error=callback)
diff --git a/python/examples/revoke.py b/python/examples/revoke.py
new file mode 100644
index 0000000..437e5b5
--- /dev/null
+++ b/python/examples/revoke.py
@@ -0,0 +1,35 @@
+## www.pubnub.com - PubNub Real-time push service in the cloud.
+# coding=utf8
+
+## PubNub Real-time Push APIs and Notifications Framework
+## Copyright (c) 2010 Stephen Blum
+## http://www.pubnub.com/
+
+
+import sys
+from Pubnub import Pubnub
+
+publish_key = len(sys.argv) > 1 and sys.argv[1] or 'pam'
+subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'pam'
+secret_key = len(sys.argv) > 3 and sys.argv[3] or 'pam'
+cipher_key = len(sys.argv) > 4 and sys.argv[4] or ''
+ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False
+
+## -----------------------------------------------------------------------
+## Initiate Pubnub State
+## -----------------------------------------------------------------------
+pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,
+ secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on)
+channel = 'hello_world'
+authkey = "abcd"
+
+# Synchronous usage
+print pubnub.revoke(channel, authkey)
+
+# Asynchronous usage
+
+
+def callback(message):
+ print(message)
+
+pubnub.revoke(channel, authkey, callback=callback, error=callback)