Skip to content

Commit 14557a4

Browse files
PubNub SDK v4.8.0 release.
1 parent 970c28d commit 14557a4

File tree

147 files changed

+5637
-3009
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+5637
-3009
lines changed

.pubnub.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
name: python
2-
version: 4.7.0
2+
version: 4.8.0
33
schema: 1
44
scm: github.com/pubnub/python
55
changelog:
6+
- version: v4.8.0
7+
date: Dec 9, 2020
8+
changes:
9+
-
10+
text: "Objects v2 implementation added to the PythonSDK with additional improvements to the test isolation within whole test suite."
11+
type: feature
612
- version: v4.7.0
713
date: Nov 19, 2020
814
changes:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [v4.8.0](https://github.com/pubnub/python/releases/tag/v4.8.0)
2+
3+
[Full Changelog](https://github.com/pubnub/python/compare/v4...v4.8.0)
4+
5+
- 🌟️ Objects v2 implementation added to the PythonSDK with additional improvements to the test isolation within whole test suite.
6+
17
## [v4.7.0](https://github.com/pubnub/python/releases/tag/v4.7.0)
28

39
[Full Changelog](https://github.com/pubnub/python/compare/v4.6.1...v4.7.0)

pubnub/callbacks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ def presence(self, pubnub, presence):
2525
def signal(self, pubnub, signal):
2626
pass
2727

28-
def user(self, pubnub, user):
28+
def channel(self, pubnub, channel):
2929
pass
3030

31-
def space(self, pubnub, space):
31+
def uuid(self, pubnub, uuid):
3232
pass
3333

3434
def membership(self, pubnub, membership):

pubnub/endpoints/access/grant.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pubnub import utils
22
from pubnub.endpoints.endpoint import Endpoint
3-
from pubnub.errors import PNERR_PAM_NO_FLAGS
3+
from pubnub.errors import PNERR_PAM_NO_FLAGS, PNERR_PAM_INVALID_ARGUMENTS
44
from pubnub.exceptions import PubNubException
55
from pubnub.enums import HttpMethod, PNOperationType
66
from pubnub.models.consumer.access_manager import PNAccessManagerGrantResult
@@ -14,14 +14,34 @@ def __init__(self, pubnub):
1414
self._auth_keys = []
1515
self._channels = []
1616
self._groups = []
17+
self._uuids = []
1718
self._read = None
1819
self._write = None
1920
self._manage = None
2021
self._delete = None
2122
self._ttl = None
23+
self._get = None
24+
self._update = None
25+
self._join = None
2226

2327
self._sort_params = True
2428

29+
def get(self, flag):
30+
self._get = flag
31+
return self
32+
33+
def update(self, flag):
34+
self._update = flag
35+
return self
36+
37+
def join(self, flag):
38+
self._join = flag
39+
return self
40+
41+
def uuids(self, uuids):
42+
utils.extend_list(self._uuids, uuids)
43+
return self
44+
2545
def auth_keys(self, auth_keys):
2646
utils.extend_list(self._auth_keys, auth_keys)
2747
return self
@@ -79,6 +99,12 @@ def custom_params(self):
7999
params['m'] = '1' if self._manage is True else '0'
80100
if self._delete is not None:
81101
params['d'] = '1' if self._delete is True else '0'
102+
if self._get is not None:
103+
params['g'] = '1' if self._get is True else '0'
104+
if self._update is not None:
105+
params['u'] = '1' if self._update is True else '0'
106+
if self._join is not None:
107+
params['j'] = '1' if self._join is True else '0'
82108

83109
if self._auth_keys:
84110
params['auth'] = utils.join_items(self._auth_keys)
@@ -89,6 +115,9 @@ def custom_params(self):
89115
if self._groups:
90116
params['channel-group'] = utils.join_items(self._groups)
91117

118+
if self._uuids:
119+
params['target-uuid'] = utils.join_items(self._uuids)
120+
92121
if self._ttl is not None:
93122
params['ttl'] = str(int(self._ttl))
94123

@@ -103,9 +132,21 @@ def http_method(self):
103132
def validate_params(self):
104133
self.validate_subscribe_key()
105134
self.validate_secret_key()
135+
self.validate_publish_key()
106136
# self.validate_channels_and_groups()
107137

108-
if self._write is None and self._read is None and self._manage is None:
138+
if self._channels and self._groups and self._uuids:
139+
raise PubNubException(
140+
pn_error=PNERR_PAM_INVALID_ARGUMENTS,
141+
errormsg="Grants for channels or channelGroups can't be changed together with grants for UUIDs")
142+
143+
if self._uuids and not self._auth_keys:
144+
raise PubNubException(pn_error=PNERR_PAM_INVALID_ARGUMENTS, errormsg="UUIDs grant management require "
145+
"providing non empty authKeys"
146+
)
147+
148+
if self._write is None and self._read is None and self._manage is None and self._get is None \
149+
and self._update is None and self._join is None:
109150
raise PubNubException(pn_error=PNERR_PAM_NO_FLAGS)
110151

111152
def create_response(self, envelope):

pubnub/endpoints/access/revoke.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ def __init__(self, pubnub):
88
self._read = False
99
self._write = False
1010
self._manage = False
11+
self._get = False
12+
self._update = False
13+
self._join = False
1114

1215
self._sort_params = True
1316

pubnub/endpoints/file_operations/publish_file_message.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections import OrderedDict
12
from pubnub.endpoints.file_operations.file_based_endpoint import FileOperationEndpoint
23
from pubnub.enums import HttpMethod, PNOperationType
34
from pubnub import utils
@@ -59,15 +60,13 @@ def _encrypt_message(self, message):
5960
return message
6061

6162
def _build_message(self):
62-
return self._encrypt_message(
63-
{
64-
"message": self._message,
65-
"file": {
66-
"id": self._file_id,
67-
"name": self._file_name
68-
}
69-
}
70-
)
63+
message = OrderedDict() # TODO: remove OrderedDict while removing EOL versions of Python (v5 release, SDK-181)
64+
message["message"] = self._message
65+
message["file"] = OrderedDict()
66+
message["file"]["id"] = self._file_id
67+
message["file"]["name"] = self._file_name
68+
69+
return self._encrypt_message(message)
7170

7271
def build_path(self):
7372
message = self._build_message()

pubnub/endpoints/file_operations/send_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def encrypt_payload(self):
5151

5252
def build_file_upload_request(self):
5353
file = self.encrypt_payload()
54-
multipart_body = OrderedDict()
54+
multipart_body = OrderedDict() # TODO: remove OrderedDict while removing EOL versions of Python (v5 release)
5555
for form_field in self._file_upload_envelope.result.data["form_fields"]:
5656
multipart_body[form_field["key"]] = (None, form_field["value"])
5757

pubnub/endpoints/membership/get_members.py

Lines changed: 0 additions & 116 deletions
This file was deleted.

0 commit comments

Comments
 (0)