gavel-team team mailing list archive
-
gavel-team team
-
Mailing list archive
-
Message #00029
[Branch ~gavel-team/gavel/gavel] Rev 8: Update api examples to reflect removal of slugs
------------------------------------------------------------
revno: 8
committer: Hilton Shumway <hillshum@xxxxxxxxx>
branch nick: master
timestamp: Fri 2010-04-02 22:29:25 -0600
message:
Update api examples to reflect removal of slugs
modified:
gavel/rest_api_curl_example.txt
--
lp:gavel
https://code.launchpad.net/~gavel-team/gavel/gavel
Your team Gavel Team is subscribed to branch lp:gavel.
To unsubscribe from this branch go to https://code.launchpad.net/~gavel-team/gavel/gavel/+edit-subscription
=== modified file 'gavel/rest_api_curl_example.txt'
--- gavel/rest_api_curl_example.txt 2010-04-02 20:14:05 +0000
+++ gavel/rest_api_curl_example.txt 2010-04-03 04:29:25 +0000
@@ -1,46 +1,20 @@
-# Create a motion with auto slug.
-# If no slug is supplied, the slug is made the primary key.
+# Create a motion by giving the text of the motion.
+# A primary key will be created.
$ curl 127.0.0.1:8000/api/motion/ -F "text=Motion 1"
+
{
"text": "Motion 1",
"slug": "1"
}$
# Get the motion.
-# Motion URLs are /api/motion/slug/
+# Motion URLs are /api/motion/pk/
$ curl 127.0.0.1:8000/api/motion/1/
{
"text": "Motion 1",
"slug": "1"
}$
-# Create a motion with custom slug.
-# A slug can be provided in the POST data.
-$ curl 127.0.0.1:8000/api/motion/ -F "text=Motion with custom slug." -F "slug=foo"
-{
- "text": "Motion with custom slug.",
- "slug": "foo"
-}$
-$ curl 127.0.0.1:8000/api/motion/foo/
-{
- "text": "Motion with custom slug.",
- "slug": "foo"
-}$
-
-# Create a motion with a custom slug from the URL.
-# A motion can be created with the slug already in place in the URL.
-$ curl 127.0.0.1:8000/api/motion/bar/ -F "text=Motion with custom slug from url."
-{
- "text": "Motion with custom slug from url.",
- "slug": "bar"
-}$
-
-$ curl 127.0.0.1:8000/api/motion/bar/
-{
- "text": "Motion with custom slug from url.",
- "slug": "bar"
-}$
-
# Record a vote.
# A vote is made by POSTing to /api/motion/slug/vote/
$ curl 127.0.0.1:8000/api/motion/1/vote/ -F "passed=False"
@@ -71,7 +45,7 @@
# Record a vote with more details.
# A vote can have more detailed data, like how many positive, negative,
# or abstaining votes.
-$ curl 127.0.0.1:8000/api/motion/foo/vote/ -F "passed=True" -F "positive=5" -F "negative=4"
+$ curl 127.0.0.1:8000/api/motion/2/vote/ -F "passed=True" -F "positive=5" -F "negative=4"
{
"positive": "5",
"abstain": null,
@@ -79,7 +53,7 @@
"passed": "True",
"datetime": "2010-04-02 14:54:04"
}$
-$ curl 127.0.0.1:8000/api/motion/foo/
+$ curl 127.0.0.1:8000/api/motion/2/
{
"vote": {
"positive": 5,
@@ -88,15 +62,14 @@
"passed": true,
"datetime": "2010-04-02 14:54:04"
},
- "text": "Motion with custom slug.",
- "slug": "foo"
+ "text": "Motion to have cookies during weekly meetings",
}$
# Record a vote without the passed field.
# The passed field is the only required field, but it can be left out if
# both positive and negative fields are supplied. The passed will be filled
# in computationally.
-$ curl 127.0.0.1:8000/api/motion/bar/vote/ -F "positive=10" -F "negative=8"
+$ curl 127.0.0.1:8000/api/motion/3/vote/ -F "positive=10" -F "negative=8"
{
"positive": 10,
"abstain": null,
@@ -117,7 +90,7 @@
# A motion can be deleted with the DELETE method.
# The associated Vote is also deleted. Votes are immutable and undeletable.
$ curl 127.0.0.1:8000/api/motion/1/ -X DELETE
-$ curl 127.0.0.1:8000/api/motion/foo/ -X DELETE
-$ curl 127.0.0.1:8000/api/motion/bar/ -X DELETE
+$ curl 127.0.0.1:8000/api/motion/2/ -X DELETE
+$ curl 127.0.0.1:8000/api/motion/3/ -X DELETE
$