Skip to content

Commit

Permalink
SK-1036 TDD - Byot option in Insert method
Browse files Browse the repository at this point in the history
- Worked on feedback
  • Loading branch information
skyflow-vivek committed Sep 7, 2023
1 parent bec8923 commit 8ab5a33
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions skyflow/errors/_skyflow_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class SkyflowErrorMessages(Enum):
BATCH_INSERT_PARTIAL_SUCCESS = "Insert Operation is partially successful"
BATCH_INSERT_FAILURE = "Insert Operation is unsuccessful"

INVALID_BYOT_TYPE = "byot option has value of type %s, expected Skyflow.BYOT"
NO_TOKENS_IN_INSERT = "Tokens are not passed in records for byot as %s"
TOKENS_PASSED_FOR_BYOT_DISABLE = "To consider tokens struct pass byot value as ENABLE"
INSUFFICIENT_TOKENS_PASSED_FOR_BYOT_ENABLE_STRICT = "For byot as ENABLE_STRICT, tokens should be passed for all fields"
Expand Down
8 changes: 6 additions & 2 deletions skyflow/vault/_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def getInsertRequestBody(data, options: InsertOptions):
if options.continueOnError == None:
requestBody.pop('continueOnError')
try:
print('request body', requestBody)
jsonBody = json.dumps(requestBody)
except Exception as e:
raise SkyflowError(SkyflowErrorCodes.INVALID_INPUT, SkyflowErrorMessages.INVALID_JSON.value % (
Expand Down Expand Up @@ -92,7 +91,12 @@ def getTableAndFields(record):

return (table, fields)

def validateTokensAndByotMode(record, byot:BYOT):
def validateTokensAndByotMode(record, byot:BYOT):

if not isinstance(byot, BYOT):
byotType = str(type(byot))
raise SkyflowError(SkyflowErrorCodes.INVALID_INPUT, SkyflowErrorMessages.INVALID_BYOT_TYPE.value % (byotType), interface=interface)

if byot == BYOT.DISABLE:
if "tokens" in record:
raise SkyflowError(SkyflowErrorCodes.INVALID_INPUT, SkyflowErrorMessages.TOKENS_PASSED_FOR_BYOT_DISABLE, interface=interface)
Expand Down

0 comments on commit 8ab5a33

Please sign in to comment.