@@ -2207,35 +2207,36 @@ def idgen(self, prefix, input_var_list, output_var):
22072207 self ._cursor ["uri" ] = self ._clean_node_value (output_var )
22082208 return self
22092209
2210- def random_idgen (self , prefix , key_list , uri ):
2211- """Randomly generates an ID and appends to the end of the key_list.
2210+ def idgen_random (self , prefix , uri ):
2211+ """Generates a unique ID with cryptographically secure random suffix.
2212+
2213+ Uses base64 encoding to generate 16-character random IDs that are
2214+ guaranteed to be unique across executions. Matches the server's
2215+ idgen_random/2 predicate and maintains consistency with the JavaScript client.
22122216
22132217 Parameters
22142218 ----------
22152219 prefix : str
2216- prefix for the id
2217- key_list : str
2218- variable to generate id for
2220+ A prefix for the IDs to be generated (e.g. "Person/")
22192221 uri : str
2220- the variable to hold the id
2222+ Variable name or output target for the generated ID
22212223
22222224 Returns
22232225 -------
22242226 WOQLQuery object
2225- query object that can be chained and/or execute
2227+ query object that can be chained and/or executed
22262228
22272229 Examples
22282230 -------
2229- >>> WOQLQuery().random_idgen("https://base.url",["page","1"],"v:obj_id ").execute(client)
2230- {'@type': 'api:WoqlResponse', 'api:status': 'api:success', 'api:variable_names': ['obj_id '], 'bindings': [{'obj_id ': 'http://base.url_page_1_rv1mfa59ekisdutnxx6zdt2fkockgah '}], 'deletes': 0, 'inserts': 0, 'transaction_retry_count': 0}
2231+ >>> WOQLQuery().idgen_random("Person/", "v:person_id ").execute(client)
2232+ {'@type': 'api:WoqlResponse', 'api:status': 'api:success', 'api:variable_names': ['person_id '], 'bindings': [{'person_id ': 'Person/aB3dEf9GhI2jK4lM '}], 'deletes': 0, 'inserts': 0, 'transaction_retry_count': 0}
22312233 """
22322234 if prefix and prefix == "args" :
2233- return ["base" , "key_list" , " uri" ]
2235+ return ["base" , "uri" ]
22342236 if self ._cursor .get ("@type" ):
22352237 self ._wrap_cursor_with_and ()
22362238 self ._cursor ["@type" ] = "RandomKey"
22372239 self ._cursor ["base" ] = self ._clean_data_value (prefix )
2238- self ._cursor ["key_list" ] = self ._data_list (key_list )
22392240 self ._cursor ["uri" ] = self ._clean_node_value (uri )
22402241 return self
22412242
0 commit comments