Skip to content

Commit 1f4972f

Browse files
Merge pull request #86 from skyflowapi/SK-815-update-readme-and-changelog-add-options-tokens-support-for-get-methods-in-python-SDK
SK-815 update readme and changelog add options tokens support for get…
2 parents 90a8020 + 1b55fb6 commit 1f4972f

1 file changed

Lines changed: 1 addition & 198 deletions

File tree

README.md

Lines changed: 1 addition & 198 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ This Python SDK is designed to help developers easily implement Skyflow into the
2525
- [Invoke Connection](#invoke-connection)
2626
- [Logging](#logging)
2727
- [Reporting a Vulnerability](#reporting-a-vulnerability)
28-
- [Get](#get-1)
29-
- [Update](#update-1)
28+
3029

3130
## Features
3231

@@ -722,199 +721,3 @@ Current the following 5 log levels are supported:
722721
## Reporting a Vulnerability
723722

724723
If you discover a potential security issue in this project, please reach out to us at security@skyflow.com. Please do not create public GitHub issues or Pull Requests, as malicious actors could potentially view them.
725-
726-
### Get
727-
728-
To retrieve data using Skyflow IDs or unique column values, use the `get(records: dict)` method. The `records` parameter takes a Dictionary that contains either an array of Skyflow IDs or a unique column name and values.
729-
730-
Note: You can use either Skyflow IDs or `unique` values to retrieve records. You can't use both at the same time.
731-
732-
```python
733-
{
734-
'records': [
735-
{
736-
'columnName': str, # Name of the unique column.
737-
'columnValues': [str], # List of unique column values.
738-
'table': str, # Name of table holding the data.
739-
'redaction': Skyflow.RedactionType, # Redaction applied to retrieved data.
740-
}
741-
]
742-
}
743-
or
744-
{
745-
'records': [
746-
{
747-
'ids': [str], # List of Skyflow IDs.
748-
'table': str, # Name of table holding the data.
749-
'redaction': Skyflow.RedactionType, # Redaction applied to retrieved data.
750-
}
751-
]
752-
}
753-
754-
```
755-
Sample usage
756-
757-
The following snippet shows how to use the `get()` method. For details, see [get_sample.py].(https://github.com/skyflowapi/skyflow-python/blob/main/samples/get_sample.py),
758-
759-
```python
760-
from skyflow.vault import RedactionType
761-
762-
skyflowIDs = ['f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9']
763-
record = {'ids': skyflowIDs, 'table': 'cards', 'redaction':RedactionType.PLAIN_TEXT}
764-
recordsWithUniqueColumn =
765-
{
766-
'table': 'test_table',
767-
'columnName': 'card_number',
768-
'columnValues': ['123456'],
769-
'redaction': RedactionType.PLAIN_TEXT
770-
}
771-
772-
invalidID = ['invalid skyflow ID']
773-
badRecord = {'ids': invalidID, 'table': 'cards', 'redaction': RedactionType.PLAIN_TEXT}
774-
775-
records = {'records': [record, badRecord]}
776-
777-
try:
778-
client.get(records)
779-
except SkyflowError as e:
780-
if e.data:
781-
print(e.data)
782-
else:
783-
print(e)
784-
```
785-
786-
Sample response:
787-
788-
```python
789-
{
790-
'records': [
791-
{
792-
'fields': {
793-
'card_number': '4111111111111111',
794-
'cvv': '127',
795-
'expiry_date': '11/35',
796-
'fullname': 'monica',
797-
'skyflow_id': 'f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9'
798-
},
799-
'table': 'cards'
800-
},
801-
{
802-
'fields': {
803-
'card_number': '123456',
804-
'cvv': '317',
805-
'expiry_date': '10/23',
806-
'fullname': 'sam',
807-
'skyflow_id': 'da26de53-95d5-4bdb-99db-8d8c66a35ff9'
808-
},
809-
'table': 'cards'
810-
}
811-
],
812-
'errors': [
813-
{
814-
'error': {
815-
'code': '404',
816-
'description': 'No Records Found'
817-
},
818-
'skyflow_ids': ['invalid skyflow id']
819-
}
820-
]
821-
}
822-
```
823-
824-
### Update
825-
826-
To update data in your vault, use the `update(records: dict, options: UpdateOptions)` method. The `records` parameter takes a Dictionary that contains records to fetch. If `UpdateTokens` is `True`, Skyflow returns tokens for the record you just updated. If `, ids if `UpdateOptions` is `False`, Skyflow returns IDs for the record you updated.
827-
828-
```python
829-
# Optional, indicates whether to return all fields for updated data. Defaults to 'true'.
830-
options: UpdateOptions
831-
```
832-
833-
```python
834-
{
835-
'records': [
836-
{
837-
'id': str, # Skyflow ID of the record to be updated.
838-
'table': str, # Name of table holding the skyflowID.
839-
'fields': {
840-
str: str # Name of the column and value to update.
841-
}
842-
}
843-
]
844-
}
845-
```
846-
Sample usage
847-
848-
The following snippet shows how to use the `update()` method. For details, see [update_sample.py](https://github.com/skyflowapi/skyflow-python/blob/main/samples/update_sample.py),
849-
850-
```python
851-
records = {
852-
'records': [
853-
{
854-
'id': '56513264-fc45-41fa-9cb0-d1ad3602bc49',
855-
'table': 'cards',
856-
'fields': {
857-
'card_number': '45678910234'
858-
}
859-
}
860-
]
861-
}
862-
try:
863-
client.update(records, UpdateOptions(True))
864-
except SkyflowError as e:
865-
if e.data:
866-
print(e.data)
867-
else:
868-
print(e)
869-
```
870-
871-
Sample response
872-
873-
`UpdateOptions` set to `True`
874-
875-
```python
876-
{
877-
'records':[
878-
{
879-
'id':'56513264-fc45-41fa-9cb0-d1ad3602bc49',
880-
'fields':{
881-
'card_number':'0051-6502-5704-9879'
882-
}
883-
}
884-
],
885-
'errors':[]
886-
}
887-
```
888-
889-
`UpdateOptions` set to `False`
890-
891-
```python
892-
{
893-
'records':[
894-
{
895-
'id':'56513264-fc45-41fa-9cb0-d1ad3602bc49'
896-
}
897-
],
898-
'errors':[]
899-
}
900-
```
901-
902-
Sample Error
903-
904-
```python
905-
{
906-
'records':[
907-
{
908-
'id':'56513264-fc45-41fa-9cb0-d1ad3602bc49'
909-
}
910-
],
911-
'errors':[
912-
{
913-
'error':{
914-
'code':404,
915-
'description':'Token for skyflowID doesn"t exist in vault - Request ID: a8def196-9569-9cb7-9974-f899f9e4bd0a'
916-
}
917-
}
918-
]
919-
}
920-
```

0 commit comments

Comments
 (0)