def build_path(self): return GetFileDownloadUrl.GET_FILE_DOWNLOAD_URL % ( self.pubnub.config.subscribe_key, utils.url_encode(self._channel), self._file_id, self._file_name )
def callback(params_to_merge): custom_params = self.custom_params() custom_params.update(params_to_merge) custom_params['pnsdk'] = self.pubnub.sdk_name custom_params['uuid'] = self.pubnub.uuid for query_key, query_value in self.pubnub._telemetry_manager.operation_latencies( ).items(): custom_params[query_key] = query_value if self.is_auth_required(): if self.pubnub._get_token(): custom_params["auth"] = self.pubnub._get_token() elif self.pubnub.config.auth_key: custom_params["auth"] = self.pubnub.config.auth_key if self.pubnub.config.secret_key: utils.sign_request(self, self.pubnub, custom_params, self.http_method(), self.build_data()) custom_params.update(self.encoded_params()) # reassign since pnsdk should be signed unencoded custom_params['pnsdk'] = utils.url_encode(self.pubnub.sdk_name) return custom_params
def callback(params_to_merge): custom_params = self.custom_params() custom_params.update(params_to_merge) custom_params['pnsdk'] = self.pubnub.sdk_name custom_params['uuid'] = self.pubnub.uuid for query_key, query_value in self.pubnub._telemetry_manager.operation_latencies().items(): custom_params[query_key] = query_value if self.is_auth_required() and self.pubnub.config.auth_key is not None: custom_params['auth'] = self.pubnub.config.auth_key if self.pubnub.config.disable_token_manager is False and self.pubnub.config.auth_key is None: tms_properties = self.get_tms_properties() if tms_properties is not None: token = self.pubnub.get_token(tms_properties) if token is not None: custom_params['auth'] = token else: logger.warning("No token found for: " + str(tms_properties)) if self.pubnub.config.secret_key is not None: utils.sign_request(self, self.pubnub, custom_params, self.http_method(), self.build_data()) custom_params.update(self.encoded_params()) # reassign since pnsdk should be signed unencoded custom_params['pnsdk'] = utils.url_encode(self.pubnub.sdk_name) return custom_params
def callback(params_to_merge): custom_params = self.custom_params() custom_params.update(params_to_merge) custom_params['pnsdk'] = self.pubnub.sdk_name custom_params['uuid'] = self.pubnub.uuid if self.is_auth_required( ) and self.pubnub.config.auth_key is not None: custom_params['auth'] = self.pubnub.config.auth_key if self.pubnub.config.secret_key is not None: custom_params['timestamp'] = str(self.pubnub.timestamp()) signed_input = (self.pubnub.config.subscribe_key + "\n" + self.pubnub.config.publish_key + "\n") operation_type = self.operation_type() if operation_type == PNOperationType.PNAccessManagerAudit: signed_input += 'audit\n' elif operation_type == PNOperationType.PNAccessManagerGrant or\ operation_type == PNOperationType.PNAccessManagerRevoke: signed_input += 'grant\n' else: signed_input += self.build_path() + "\n" _custom_params = custom_params.copy() if custom_params.get('channel'): _custom_params['channel'] = six.moves.urllib.parse.unquote( _custom_params['channel']) signed_input += utils.prepare_pam_arguments(_custom_params) signature = utils.sign_sha256(self.pubnub.config.secret_key, signed_input) # REVIEW: add encoder map to not hardcode encoding here if operation_type == PNOperationType.PNPublishOperation and 'meta' in custom_params: custom_params['meta'] = utils.url_encode( custom_params['meta']) if operation_type == PNOperationType.PNSetStateOperation and 'state' in custom_params: custom_params['state'] = utils.url_encode( custom_params['state']) custom_params['signature'] = signature # reassign since pnsdk should be signed unencoded custom_params['pnsdk'] = utils.url_encode(self.pubnub.sdk_name) return custom_params
def callback(params_to_merge): operation_type = self.operation_type() custom_params = self.custom_params() custom_params.update(params_to_merge) custom_params['pnsdk'] = self.pubnub.sdk_name custom_params['uuid'] = self.pubnub.uuid for query_key, query_value in self.pubnub._telemetry_manager.operation_latencies( ).items(): custom_params[query_key] = query_value if self.is_auth_required( ) and self.pubnub.config.auth_key is not None: custom_params['auth'] = self.pubnub.config.auth_key if self.pubnub.config.secret_key is not None: custom_params['timestamp'] = str(self.pubnub.timestamp()) signed_input = (self.pubnub.config.subscribe_key + "\n" + self.pubnub.config.publish_key + "\n") if operation_type == PNOperationType.PNAccessManagerAudit: signed_input += 'audit\n' elif operation_type == PNOperationType.PNAccessManagerGrant or \ operation_type == PNOperationType.PNAccessManagerRevoke: signed_input += 'grant\n' else: signed_input += self.build_path() + "\n" signed_input += utils.prepare_pam_arguments(custom_params) signature = utils.sign_sha256(self.pubnub.config.secret_key, signed_input) custom_params['signature'] = signature # REVIEW: add encoder map to not hardcode encoding here if operation_type == PNOperationType.PNPublishOperation and 'meta' in custom_params: custom_params['meta'] = utils.url_encode(custom_params['meta']) if operation_type == PNOperationType.PNSetStateOperation and 'state' in custom_params: custom_params['state'] = utils.url_encode( custom_params['state']) # reassign since pnsdk should be signed unencoded custom_params['pnsdk'] = utils.url_encode(self.pubnub.sdk_name) return custom_params
def build_path(self): if self._use_post: return Publish.PUBLISH_POST_PATH % (self.pubnub.config.publish_key, self.pubnub.config.subscribe_key, utils.url_encode(self._channel), 0) else: cipher = self.pubnub.config.cipher_key stringified_message = utils.write_value_as_string(self._message) if cipher is not None: stringified_message = '"' + self.pubnub.config.crypto.encrypt(cipher, stringified_message) + '"' stringified_message = utils.url_encode(stringified_message) return Publish.PUBLISH_GET_PATH % (self.pubnub.config.publish_key, self.pubnub.config.subscribe_key, utils.url_encode(self._channel), 0, stringified_message)
def build_path(self): if self._use_post: return Fire.FIRE_POST_PATH % (self.pubnub.config.publish_key, self.pubnub.config.subscribe_key, utils.url_encode(self._channel), 0) else: cipher = self.pubnub.config.cipher_key stringified_message = utils.write_value_as_string(self._message) if cipher is not None: stringified_message = '"' + self.pubnub.config.crypto.encrypt(cipher, stringified_message) + '"' stringified_message = utils.url_encode(stringified_message) return Fire.FIRE_GET_PATH % (self.pubnub.config.publish_key, self.pubnub.config.subscribe_key, utils.url_encode(self._channel), 0, stringified_message)
def custom_params(self): params = {} if self._meta is not None: params['meta'] = utils.write_value_as_string(self._meta) params["store"] = "0" params["norep"] = "1" if self.pubnub.config.auth_key is not None: params["auth"] = utils.url_encode(self.pubnub.config.auth_key) return params
def build_path(self): if self._include_message_actions is False: return FetchMessages.FETCH_MESSAGES_PATH % ( self.pubnub.config.subscribe_key, utils.join_channels(self._channels)) else: return FetchMessages.FETCH_MESSAGES_WITH_ACTIONS_PATH % ( self.pubnub.config.subscribe_key, utils.url_encode(self._channels[0]))
def callback(params_to_merge): operation_type = self.operation_type() custom_params = self.custom_params() custom_params.update(params_to_merge) custom_params['pnsdk'] = self.pubnub.sdk_name custom_params['uuid'] = self.pubnub.uuid for query_key, query_value in self.pubnub._telemetry_manager.operation_latencies( ).items(): custom_params[query_key] = query_value if self.is_auth_required( ) and self.pubnub.config.auth_key is not None: custom_params['auth'] = self.pubnub.config.auth_key if self.pubnub.config.disable_token_manager is False and self.pubnub.config.auth_key is None: tms_properties = self.get_tms_properties() if tms_properties is not None: token = self.pubnub.get_token(tms_properties) if token is not None: custom_params['auth'] = token else: logger.warning("No token found for: " + str(tms_properties)) if self.pubnub.config.secret_key is not None: utils.sign_request(self, self.pubnub, custom_params, self.http_method(), self.build_data()) # REVIEW: add encoder map to not hardcode encoding here if operation_type == PNOperationType.PNPublishOperation and 'meta' in custom_params: custom_params['meta'] = utils.url_encode(custom_params['meta']) if operation_type == PNOperationType.PNSetStateOperation and 'state' in custom_params: custom_params['state'] = utils.url_encode( custom_params['state']) # reassign since pnsdk should be signed unencoded custom_params['pnsdk'] = utils.url_encode(self.pubnub.sdk_name) return custom_params
def callback(params_to_merge): operation_type = self.operation_type() custom_params = self.custom_params() custom_params.update(params_to_merge) custom_params['pnsdk'] = self.pubnub.sdk_name custom_params['uuid'] = self.pubnub.uuid for query_key, query_value in self.pubnub._telemetry_manager.operation_latencies().items(): custom_params[query_key] = query_value if self.is_auth_required() and self.pubnub.config.auth_key is not None: custom_params['auth'] = self.pubnub.config.auth_key if self.pubnub.config.secret_key is not None: custom_params['timestamp'] = str(self.pubnub.timestamp()) signed_input = (self.pubnub.config.subscribe_key + "\n" + self.pubnub.config.publish_key + "\n") if operation_type == PNOperationType.PNAccessManagerAudit: signed_input += 'audit\n' elif operation_type == PNOperationType.PNAccessManagerGrant or \ operation_type == PNOperationType.PNAccessManagerRevoke: signed_input += 'grant\n' else: signed_input += self.build_path() + "\n" signed_input += utils.prepare_pam_arguments(custom_params) signature = utils.sign_sha256(self.pubnub.config.secret_key, signed_input) custom_params['signature'] = signature # REVIEW: add encoder map to not hardcode encoding here if operation_type == PNOperationType.PNPublishOperation and 'meta' in custom_params: custom_params['meta'] = utils.url_encode(custom_params['meta']) if operation_type == PNOperationType.PNSetStateOperation and 'state' in custom_params: custom_params['state'] = utils.url_encode(custom_params['state']) # reassign since pnsdk should be signed unencoded custom_params['pnsdk'] = utils.url_encode(self.pubnub.sdk_name) return custom_params
def custom_params(self): params = {} inclusions = [] if isinstance(self, IncludeCustomEndpoint): if self._include_custom: inclusions.append("custom") if isinstance(self, UUIDIncludeEndpoint): if self._uuid_details_level: if self._uuid_details_level == UUIDIncludeEndpoint.UUID: inclusions.append("uuid") elif self._uuid_details_level == UUIDIncludeEndpoint.UUID_WITH_CUSTOM: inclusions.append("uuid.custom") if isinstance(self, ChannelIncludeEndpoint): if self._channel_details_level: if self._channel_details_level == ChannelIncludeEndpoint.CHANNEL: inclusions.append("channel") elif self._channel_details_level == ChannelIncludeEndpoint.CHANNEL_WITH_CUSTOM: inclusions.append("channel.custom") if isinstance(self, ListEndpoint): if self._filter: params["filter"] = utils.url_encode(str(self._filter)) if self._limit: params["limit"] = int(self._limit) if self._include_total_count: params["count"] = bool(self._include_total_count) if self._sort_keys: joined_sort_params_array = [] for sort_key in self._sort_keys: joined_sort_params_array.append( "%s:%s" % (sort_key.key_str(), sort_key.dir_str())) params["sort"] = ",".join(joined_sort_params_array) if self._page: if isinstance(self._page, Next): params["start"] = self._page.hash() elif isinstance(self._page, Previous): params["end"] = self._page.hash() else: raise ValueError() if len(inclusions) > 0: params["include"] = ",".join(inclusions) return params
def custom_params(self): params = {} if self._meta is not None: params['meta'] = utils.write_value_as_string(self._meta) if self._should_store is not None: if self._should_store: params["store"] = "1" else: params["store"] = "0" # REVIEW: should auth key be assigned here? if self.pubnub.config.auth_key is not None: params["auth"] = utils.url_encode(self.pubnub.config.auth_key) return params
def custom_params(self): params = {} if len(self._groups) > 0: params['channel-group'] = utils.join_items_and_encode(self._groups) if self._filter_expression is not None and len(self._filter_expression) > 0: params['filter-expr'] = utils.url_encode(self._filter_expression) if self._timetoken is not None: params['tt'] = str(self._timetoken) if self._region is not None: params['tr'] = self._region if not self.pubnub.config.heartbeat_default_values: params['heartbeat'] = self.pubnub.config.presence_timeout return params
def custom_params(self): params = {} if self._start is not None: params['start'] = self._start if self._end is not None and self._start is None: params['end'] = self._end if self._count is True: params['count'] = True if self._limit != GetSpaceMemberships.MAX_LIMIT: params['limit'] = self._limit if self._include: params['include'] = utils.join_items(self._include) if self._filter: params['filter'] = utils.url_encode(self._filter) return params
def custom_params(self): params = {} if self._meta is not None: params['meta'] = utils.write_value_as_string(self._meta) if self._should_store is not None: if self._should_store: params["store"] = "1" else: params["store"] = "0" if self._replicate is not None: if self._replicate: params["replicate"] = "1" else: params["replicate"] = "0" # REVIEW: should auth key be assigned here? if self.pubnub.config.auth_key is not None: params["auth"] = utils.url_encode(self.pubnub.config.auth_key) return params
def build_path(self): return HistoryDelete.HISTORY_DELETE_PATH % ( self.pubnub.config.subscribe_key, utils.url_encode(self._channel) )
def build_path(self): return AddMessageAction.ADD_MESSAGE_ACTION_PATH % ( self.pubnub.config.subscribe_key, utils.url_encode( self._channel), self._message_action.message_timetoken)
def build_path(self): return ListFiles.LIST_FILES_URL % (self.pubnub.config.subscribe_key, utils.url_encode(self._channel))
def build_path(self): return AddChannelToChannelGroup.ADD_PATH % ( self.pubnub.config.subscribe_key, utils.url_encode(self._channel_group))
def build_path(self): return RevokeToken.REVOKE_TOKEN_PATH % ( self.pubnub.config.subscribe_key, utils.url_encode(self.token))
def url_encode(data): return utils.url_encode(utils.write_value_as_string(data))
def build_path(self): return GetMessageActions.GET_MESSAGE_ACTIONS_PATH % ( self.pubnub.config.subscribe_key, utils.url_encode(self._channel))
def build_path(self): stringified_message = utils.write_value_as_string(self._message) msg = utils.url_encode(stringified_message) return Signal.SIGNAL_PATH % (self.pubnub.config.publish_key, self.pubnub.config.subscribe_key, utils.url_encode(self._channel), msg)
def build_path(self): return WhereNow.WHERE_NOW_PATH % (self.pubnub.config.subscribe_key, utils.url_encode(self._uuid))
def build_path(self): return DeleteFile.DELETE_FILE_URL % (self.pubnub.config.subscribe_key, utils.url_encode(self._channel), self._file_id, self._file_name)
def build_path(self): return RemoveMessageAction.REMOVE_MESSAGE_ACTION_PATH % ( self.pubnub.config.subscribe_key, utils.url_encode(self._channel), self._message_timetoken, self._action_timetoken)
def build_path(self): message = self._build_message() return PublishFileMessage.PUBLISH_FILE_MESSAGE % ( self.pubnub.config.publish_key, self.pubnub.config.subscribe_key, utils.url_encode(self._channel), utils.url_write(message))
def build_path(self): return ListChannelsInChannelGroup.LIST_PATH % ( self.pubnub.config.subscribe_key, utils.url_encode(self._channel_group))
def build_path(self): return RemoveChannelGroup.REMOVE_PATH % ( self.pubnub.config.subscribe_key, utils.url_encode(self._channel_group))
def build_path(self): return GetState.GET_STATE_PATH % ( self.pubnub.config.subscribe_key, utils.join_channels(self._channels), utils.url_encode(self.pubnub.uuid) )
def build_path(self): return FetchFileUploadS3Data.GENERATE_FILE_UPLOAD_DATA % ( self.pubnub.config.subscribe_key, utils.url_encode(self._channel))
def build_path(self): return GetState.GET_STATE_PATH % (self.pubnub.config.subscribe_key, utils.join_channels(self._channels), utils.url_encode(self._uuid))