From 67edaebd40d871e164a577a96bf16f75798e431a Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Tue, 16 Feb 2016 18:17:43 -0800 Subject: [PATCH] gmail updates --- urb/zod/ape/gmail/split.hoon | 71 ++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 urb/zod/ape/gmail/split.hoon diff --git a/urb/zod/ape/gmail/split.hoon b/urb/zod/ape/gmail/split.hoon new file mode 100644 index 000000000..e6944cc9a --- /dev/null +++ b/urb/zod/ape/gmail/split.hoon @@ -0,0 +1,71 @@ +!: +|% +:: Splits a path into the endpoint prefix and the remainder, +:: which is assumed to be a path within the JSON object. We +:: choose the longest legal endpoint prefix. +:: +++ split + |= pax=path + :: =- ~& [%pax pax - (valid-endpoint pax)] - + =+ l=(lent pax) + |- ^- [path path] + ?: ?=(valid-get-endpoint (scag l pax)) + [(scag l pax) (slag l pax)] + ?~ l + ~& %bad-endpoint + ~|(%bad-endpoint !!) + $(l (dec l)) +:: +:: These are all the github GET endpoints, sorted with +:: `env LC_ALL=C sort` +:: +:: end-points include required query parameters +++ valid-get-endpoint + $? [%drafts id=@t ~] + [%drafts ~] + [%history ~] + [%labels id=@t ~] + [%labels ~] + [%messages id=@t %attachments id=@t ~] + [%messages id=@t ~] + [%messages ~] + [%profile ~] + [%threads id=@t ~] + [%threads ~] + == + +++ vaild-post-endpoint + $? [%drafts %send ~] + [%drafts ~] + [%messages id=@t %modify ~] + [%messages id=@t %trash ~] + [%messages id=@t %untrash ~] + [%messages %import ~] + [%messages %send ~] + [%messages ~] + [%labels ~] + [%threads id=@t %trash ~] + [%threads id=@t %untrash ~] + [%threads id=@t %modify] + [%stop ~] + [%watch ~] + == + +++ valid-delete-endpoint + $? [%drafts id=@t ~] + [%labels id=@t ~] + [%messages id=@t ~] + [%thread id=@t ~] + == +++ valid-put-endpoint + $? [%drafts id=@t ~] + [%labels id=@t ~] + == +++ valid-patch-endpoint + $? [%labels id=@t ~] + == + +-- + +:: +