Skip to content

Commit 2765f44

Browse files
authored
added bulk datastore api
1 parent 7b05d0a commit 2765f44

File tree

1 file changed

+93
-78
lines changed

1 file changed

+93
-78
lines changed

docs/API.md

Lines changed: 93 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,98 @@ curl https://shuffler.io/api/v1/workflows/{workflow_id}/executions/{execution_id
243243
{"success": true}
244244
```
245245

246+
## Datastore API
247+
Datastore is a persistent storage mechanism you can use for workflows to talk to each other between executions, or for normal storage. Below are the endpoints related to datastore (cache) creation, listing, deletion and more. This API is available to Python apps by using self.set_cache("key", "value") and self.get_cache("key")
248+
249+
### Add a key
250+
To add a key to a specific category, add `"category": "name"` to the JSON body.
251+
252+
Methods: POST, PUT
253+
254+
```bash
255+
curl https://shuffler.io/api/v1/orgs/{org_id}/set_cache -H "Authorization: Bearer APIKEY" -d '{"key":"hi", "value":"1234", "category": "category"}'
256+
```
257+
258+
259+
**Success response**
260+
```json
261+
{"success": true}
262+
```
263+
264+
### Add multiple keys
265+
To add a key to a specific category, add `"category": "name"` to the JSON body. Only keys of the first discovered category will be added.
266+
267+
Methods: POST, PUT
268+
269+
```bash
270+
curl https://shuffler.io/api/v2/datastore?bulk=true -H "Authorization: Bearer APIKEY" -d '[{"key":"hi", "value":"1234", "category": "category"}]'
271+
```
272+
273+
274+
**Success response**
275+
```json
276+
{"success": true}
277+
```
278+
279+
280+
### Get a key
281+
Search for a cache key. For keys set in a workflow, it may unavailable with the normal API, and require execution_id & authorization in the JSON body.
282+
283+
To get a key from a specific category, add `"category": "name"` to the JSON body.
284+
285+
Methods: POST
286+
287+
```bash
288+
curl https://shuffler.io/api/v1/orgs/{org_id}/get_cache -H "Authorization: Bearer APIKEY" -d '{"org_id": "ORG_ID", "key": "hi"}'
289+
```
290+
291+
292+
**Success response**
293+
```json
294+
{"success":false,"workflow_id":"99951014-f0b1-473d-a474-4dc9afecaa75","execution_id":"f0b2b4e9-90ca-4835-bdd4-2889ef5f926f","org_id":"2e7b6a08-b63b-4fc2-bd70-718091509db1","key":"hi","value":"1234"}
295+
```
296+
297+
298+
### List all keys
299+
List existing datastore (cache) keys. By default, this will include the 50 last modified keys from any category.
300+
301+
To list keys from a specific category, ?category=<name> to the URL.
302+
303+
Available queries:
304+
- top: default 50. How many keys to return.
305+
- cursor: to get the next page
306+
- category: the category to get
307+
308+
Methods: GET
309+
310+
```bash
311+
curl https://shuffler.io/api/v1/orgs/{org_id}/list_cache -H "Authorization: Bearer APIKEY"
312+
```
313+
314+
315+
**Success response**
316+
```json
317+
{"success":true,"keys":[{"success":false,"workflow_id":"99951014-f0b1-473d-a474-4dc9afecaa75","execution_id":"f0b2b4e9-90ca-4835-bdd4-2889ef5f926f","org_id":"2e7b6a08-b63b-4fc2-bd70-718091509db1","key":"hi","value":"1234"}]}
318+
```
319+
320+
### Delete a key
321+
Deletes a key, completely removing all references to it.
322+
323+
To delete a key from a specific category, add `"category": "name"` to the JSON body.
324+
325+
Methods: DELETE
326+
327+
```bash
328+
curl https://shuffler.io/api/v1/orgs/{org_id}/delete_cache -H "Authorization: Bearer APIKEY" -d '{"org_id": "ORG_ID", "key": "hi"}'
329+
```
330+
331+
332+
**Success response**
333+
```json
334+
{"success": true}
335+
```
336+
337+
246338
## App API
247339
Apps are the building blocks used in [workflows](/docs/apps#workflows), as they contain the actions to be executed. First of all, there are two types of apps:
248340

@@ -589,83 +681,6 @@ curl https://shuffler.io/api/v1/users/generateapikey -H "Authorization: Bearer A
589681
{"success": true, "username": "username", "verified": false, "apikey": "new apikey"}
590682
```
591683

592-
## Datastore API
593-
Datastore is a persistent storage mechanism you can use for workflows to talk to each other between executions, or for normal storage. Below are the endpoints related to datastore (cache) creation, listing, deletion and more. This API is available to Python apps by using self.set_cache("key", "value") and self.get_cache("key")
594-
595-
### Add a key
596-
To add or edit a cache key use
597-
598-
To add a key to a specific category, add `"category": "name"` to the JSON body.
599-
600-
Methods: POST, PUT
601-
602-
```bash
603-
curl https://shuffler.io/api/v1/orgs/{org_id}/set_cache -H "Authorization: Bearer APIKEY" -d '{"key":"hi", "value":"1234"}'
604-
```
605-
606-
607-
**Success response**
608-
```json
609-
{"success": true}
610-
```
611-
612-
### Get a key
613-
Search for a cache key. For keys set in a workflow, it may unavailable with the normal API, and require execution_id & authorization in the JSON body.
614-
615-
To get a key from a specific category, add `"category": "name"` to the JSON body.
616-
617-
Methods: POST
618-
619-
```bash
620-
curl https://shuffler.io/api/v1/orgs/{org_id}/get_cache -H "Authorization: Bearer APIKEY" -d '{"org_id": "ORG_ID", "key": "hi"}'
621-
```
622-
623-
624-
**Success response**
625-
```json
626-
{"success":false,"workflow_id":"99951014-f0b1-473d-a474-4dc9afecaa75","execution_id":"f0b2b4e9-90ca-4835-bdd4-2889ef5f926f","org_id":"2e7b6a08-b63b-4fc2-bd70-718091509db1","key":"hi","value":"1234"}
627-
```
628-
629-
630-
### List all keys
631-
List existing datastore (cache) keys. By default, this will include the 50 last modified keys from any category.
632-
633-
To list keys from a specific category, ?category=<name> to the URL.
634-
635-
Available queries:
636-
- top: default 50. How many keys to return.
637-
- cursor: to get the next page
638-
- category: the category to get
639-
640-
Methods: GET
641-
642-
```bash
643-
curl https://shuffler.io/api/v1/orgs/{org_id}/list_cache -H "Authorization: Bearer APIKEY"
644-
```
645-
646-
647-
**Success response**
648-
```json
649-
{"success":true,"keys":[{"success":false,"workflow_id":"99951014-f0b1-473d-a474-4dc9afecaa75","execution_id":"f0b2b4e9-90ca-4835-bdd4-2889ef5f926f","org_id":"2e7b6a08-b63b-4fc2-bd70-718091509db1","key":"hi","value":"1234"}]}
650-
```
651-
652-
### Delete a key
653-
Deletes a key, completely removing all references to it.
654-
655-
To delete a key from a specific category, add `"category": "name"` to the JSON body.
656-
657-
Methods: DELETE
658-
659-
```bash
660-
curl https://shuffler.io/api/v1/orgs/{org_id}/delete_cache -H "Authorization: Bearer APIKEY" -d '{"org_id": "ORG_ID", "key": "hi"}'
661-
```
662-
663-
664-
**Success response**
665-
```json
666-
{"success": true}
667-
```
668-
669684
## File API
670685
Below are the endpoints related to file creation, uploading, downloading, listing and more. This API is available to Python apps by using self.set_files(files) and self.get_file(file_id)
671686

@@ -1154,4 +1169,4 @@ As you can see, I triggered this Singul execution through the Singul app (not th
11541169
<img src="https://github.com/frikky/shuffle-docs/blob/master/assets/singul-debugging-step2.png?raw=true">
11551170

11561171

1157-
Based on the output, and the input mentioned in "Body", you should be able to figure out what is going on here.
1172+
Based on the output, and the input mentioned in "Body", you should be able to figure out what is going on here.

0 commit comments

Comments
 (0)