-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Lambda support for Skygear Data Type #195
- Loading branch information
Showing
5 changed files
with
271 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import skygear | ||
from skygear.models import Location, Record, RecordID | ||
|
||
|
||
@skygear.op('hello') | ||
def hello(): | ||
""" | ||
This lamda returns some skydb types to the caller. This demonstrates | ||
the lambda can return skydb types. | ||
``` | ||
curl -X "POST" "http://localhost:3000" \ | ||
-H 'Content-Type: application/json; charset=utf-8' \ | ||
-d $'{ | ||
"api_key": "secret", | ||
"action": "hello" | ||
}' | ||
``` | ||
""" | ||
return [ | ||
1, | ||
2, | ||
True, | ||
"hello", | ||
Location(1, 2), | ||
Record( | ||
id=RecordID("note", "99D92DBA-74D5-477F-B35E-F735E21B2DD5"), | ||
owner_id="OWNER_ID", | ||
acl=None, | ||
data={ | ||
"content": "Hello World!", | ||
} | ||
), | ||
{ | ||
'location': Location(1, 2) | ||
} | ||
] | ||
|
||
|
||
@skygear.op('echo') | ||
def echo(value): | ||
""" | ||
This lamda copies the lambda value and return it to the caller. | ||
``` | ||
curl -X "POST" "http://localhost:3000" \ | ||
-H 'Content-Type: application/json; charset=utf-8' \ | ||
-d $'{ | ||
"api_key": "secret", | ||
"action": "echo", | ||
"args": [ | ||
{ | ||
"location": {"$lng":1,"$type":"geo","$lat":2} | ||
} | ||
] | ||
}' | ||
``` | ||
""" | ||
return value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.