diff --git a/samples/vault_api/update_record.py b/samples/vault_api/update_record.py index 367e4ac..ad61718 100644 --- a/samples/vault_api/update_record.py +++ b/samples/vault_api/update_record.py @@ -46,7 +46,7 @@ ) # sample data -update_data = {'id': '', '': ''} +update_data = {'skyflow_id': '', '': ''} update_request = UpdateRequest(table='TABLE_NAME', data=update_data) diff --git a/skyflow/utils/validations/_validations.py b/skyflow/utils/validations/_validations.py index c1dbe3f..ccea4b1 100644 --- a/skyflow/utils/validations/_validations.py +++ b/skyflow/utils/validations/_validations.py @@ -441,10 +441,10 @@ def validate_get_request(logger, request): def validate_update_request(logger, request): skyflow_id = "" - field = {key: value for key, value in request.data.items() if key != "id"} + field = {key: value for key, value in request.data.items() if key != "skyflow_id"} try: - skyflow_id = request.data.get("id") + skyflow_id = request.data.get("skyflow_id") except Exception: log_error_log(SkyflowMessages.ErrorLogs.SKYFLOW_ID_IS_REQUIRED.value.format("UPDATE"), logger=logger) @@ -499,9 +499,6 @@ def validate_update_request(logger, request): SkyflowMessages.Error.INSUFFICIENT_TOKENS_PASSED_FOR_TOKEN_STRICT_ENABLE_STRICT.value, invalid_input_error_code) - if 'id' not in request.data: - raise SkyflowError(SkyflowMessages.Error.IDS_KEY_ERROR.value, invalid_input_error_code) - def validate_detokenize_request(logger, request): if not isinstance(request.redaction_type, RedactionType): raise SkyflowError(SkyflowMessages.Error.INVALID_REDACTION_TYPE.value.format(type(request.redaction_type)), invalid_input_error_code) diff --git a/skyflow/vault/controller/_vault.py b/skyflow/vault/controller/_vault.py index ebdc924..06a5508 100644 --- a/skyflow/vault/controller/_vault.py +++ b/skyflow/vault/controller/_vault.py @@ -103,7 +103,7 @@ def update(self, request: UpdateRequest): validate_update_request(self.__vault_client.get_logger(), request) log_info(SkyflowMessages.Info.UPDATE_REQUEST_RESOLVED.value, self.__vault_client.get_logger()) self.__initialize() - field = {key: value for key, value in request.data.items() if key != "id"} + field = {key: value for key, value in request.data.items() if key != "skyflow_id"} record = V1FieldRecords(fields=field, tokens = request.tokens) payload = RecordServiceUpdateRecordBody(record=record, tokenization=request.return_tokens, byot=request.token_strict.value) @@ -113,7 +113,7 @@ def update(self, request: UpdateRequest): api_response = records_api.record_service_update_record( self.__vault_client.get_vault_id(), request.table, - request.data.get("id"), + request.data.get("skyflow_id"), payload ) log_info(SkyflowMessages.Info.UPDATE_SUCCESS.value, self.__vault_client.get_logger()) diff --git a/tests/vault/controller/test__vault.py b/tests/vault/controller/test__vault.py index cdb49ef..4d34db1 100644 --- a/tests/vault/controller/test__vault.py +++ b/tests/vault/controller/test__vault.py @@ -145,7 +145,7 @@ def test_update_successful(self, mock_parse_response, mock_validate): # Mock request request = UpdateRequest( table=TABLE_NAME, - data={"id": "12345", "field": "new_value"}, + data={"skyflow_id": "12345", "field": "new_value"}, tokens=None, return_tokens=True, token_strict=TokenStrict.DISABLE @@ -183,7 +183,7 @@ def test_update_successful(self, mock_parse_response, mock_validate): records_api.record_service_update_record.assert_called_once_with( VAULT_ID, request.table, - request.data["id"], + request.data["skyflow_id"], expected_payload ) mock_parse_response.assert_called_once_with(mock_api_response)