[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/srht 0b37b7225f 24/27: Add support for pagination.
From: |
ELPA Syncer |
Subject: |
[elpa] externals/srht 0b37b7225f 24/27: Add support for pagination. |
Date: |
Tue, 17 May 2022 22:58:01 -0400 (EDT) |
branch: externals/srht
commit 0b37b7225f365e1916983cdc3abf9edda80e5d82
Author: Aleksandr Vityazev <avityazev@posteo.org>
Commit: Aleksandr Vityazev <avityazev@posteo.org>
Add support for pagination.
---
lisp/srht-git.el | 66 +++++++++++++++++++++++++++++-------------------------
lisp/srht-paste.el | 16 +++++++------
lisp/srht.el | 7 +++---
3 files changed, 49 insertions(+), 40 deletions(-)
diff --git a/lisp/srht-git.el b/lisp/srht-git.el
index 96fd7a3e19..8f5adbd8ac 100644
--- a/lisp/srht-git.el
+++ b/lisp/srht-git.el
@@ -30,11 +30,11 @@
(defvar srht-git-repos nil
"Authenticated user repos.")
-(defun srht-git--make-crud (path &optional body form)
+(defun srht-git--make-crud (path &optional query body form)
"Make crud for git service.
PATH is the path for the URI. BODY is the body sent to the URI.
-FORM is a content type."
- (srht-generic-crud 'git path body form))
+FORM is a content type. QUERY is the query for the URI."
+ (srht-generic-crud 'git path query body form))
(defun srht-git-user (&optional username)
"Retrieves a user resource.
@@ -44,13 +44,15 @@ If USERNAME is nil, the authenticated user is assumed."
"/api/user")))
(srht-git--make-crud path)))
-(defun srht-git-repos (&optional username)
+(defun srht-git-repos (&optional username query)
"Retrive list of repository resources owned by this USERNAME.
-If USERNAME is nil the authenticated user is assumed."
+If USERNAME is nil the authenticated user is assumed.
+QUERY is the query for the URI. To retrieve the next page of results,
+add start=:id to your QUERY, using the :id given by \"next\"."
(let ((path (if username
(format "/api/~%s/repos" (string-trim-left username "~"))
"/api/repos")))
- (srht-git--make-crud path)))
+ (srht-git--make-crud path query)))
(cl-defun srht-git-make (&key visibility description name)
"Make paste parameters.
@@ -81,14 +83,16 @@ When creating repository omit REPO-NAME and specify DETAILS
(srht-git--make-crud
(format "/api/~%s/repos/%s" (string-trim-left username "~") repo-name)))
((and (stringp repo-name) details)
- (srht-git--make-crud (format "/api/repos/%s" repo-name)
- (apply #'srht-git-make details)))
+ (srht-git--make-crud
+ (format "/api/repos/%s" repo-name) nil (apply #'srht-git-make details)))
((stringp repo-name) (srht-git--make-crud (format "/api/repos/%s"
repo-name)))
- (t (srht-git--make-crud "/api/repos" (apply #'srht-git-make details)))))
+ (t (srht-git--make-crud "/api/repos" nil (apply #'srht-git-make details)))))
-(defmacro srht-git--endpoint (endpoint name username &optional body form)
+(defmacro srht-git--endpoint (endpoint name username &optional query body form)
"Generate crud for ENDPOINT and repository NAME.
If USERNAME is nil the authenticated user is assumed.
+QUERY is the query for the URI. To retrieve the next page of results,
+add start=:id to your QUERY, using the :id given by \"next\".
BODY is the body sent to the URI.
FORM is a content type."
(let ((path (gensym "path")))
@@ -96,14 +100,14 @@ FORM is a content type."
(format "/api/~%s/repos/%s/%s"
(string-trim-left ,username "~") ,name ,endpoint)
(format "/api/repos/%s/%s" ,name ,endpoint))))
- (srht-git--make-crud ,path ,body ,form))))
+ (srht-git--make-crud ,path ,query ,body ,form))))
-(defun srht-git--endpoint-widen (endpoint name end &optional username body)
+(defun srht-git--endpoint-widen (endpoint name end &optional username
body-or-query)
"Extends the ENDPOINT for the repository NAME to include END.
If USERNAME is nil the authenticated user is assumed.
-BODY is the body sent to the URI."
- (let* ((plist (if body
- (funcall endpoint name username body)
+BODY-OR-QUERY is the body or query sent to the URI."
+ (let* ((plist (if body-or-query
+ (funcall endpoint name username body-or-query)
(funcall endpoint name username)))
(path (plist-get plist :path)))
(setf (plist-get plist :path)
@@ -121,15 +125,17 @@ If USERNAME is nil the authenticated user is assumed.
BODY is the body sent to the URI. FORM is a content type."
(srht-git--endpoint "readme" name username body form))
-(defun srht-git-repo-refs (name &optional username)
+(defun srht-git-repo-refs (name &optional username query)
"Endpoints for fetching git data from repository NAME.
-If USERNAME is nil the authenticated user is assumed."
- (srht-git--endpoint "refs" name username))
+If USERNAME is nil the authenticated user is assumed.
+QUERY is the query for the URI."
+ (srht-git--endpoint "refs" name username query))
-(defun srht-git-repo-log (name &optional username)
+(defun srht-git-repo-log (name &optional username query)
"List of the latest commit log for repository NAME.
-If USERNAME is nil the authenticated user is assumed."
- (srht-git--endpoint "log" name username))
+If USERNAME is nil the authenticated user is assumed.
+QUERY is the query for the URI."
+ (srht-git--endpoint "log" name username query))
(defun srht-git-repo-artifact (name ref body &optional username)
"Attaches a file artifact to the specified REF and repository NAME.
@@ -137,25 +143,25 @@ Note: this endpoint does not accept JSON. Submit your
request
as `multipart/form-data', with a single field: file in BODY."
(srht-git--endpoint-widen #'srht-git--artifact name ref username body))
-(defun srht-git-repo-log-ref (name ref &optional username)
+(defun srht-git-repo-log-ref (name ref &optional username query)
"List of the latest commit resources starting from the given REF.
NAME is a repository name. If USERNAME is nil the authenticated user
-is assumed."
- (srht-git--endpoint-widen #'srht-git-repo-log name ref username))
+is assumed. QUERY is the query for the URI."
+ (srht-git--endpoint-widen #'srht-git-repo-log name ref username query))
-(defun srht-git-repo-tree-ref (name ref &optional username)
+(defun srht-git-repo-tree-ref (name ref &optional username query)
"Return the tree resource for the given REF.
Following the parent trees until the requested tree is found.
In other words, this lists the contents of a subdirectory by path.
NAME is a repository name. If USERNAME is nil the authenticated user
-is assumed."
- (srht-git--endpoint-widen #'srht-git-repo-tree name ref username))
+is assumed. QUERY is the query for the URI."
+ (srht-git--endpoint-widen #'srht-git-repo-tree name ref username query))
-(defun srht-git-repo-tree-id (name id &optional username)
+(defun srht-git-repo-tree-id (name id &optional username query)
"Return the tree resource with the given ID.
NAME is a repository name. If USERNAME is nil the authenticated user
-is assumed."
- (srht-git--endpoint-widen #'srht-git-repo-tree name id username))
+is assumed. QUERY is the query for the URI."
+ (srht-git--endpoint-widen #'srht-git-repo-tree name id username query))
(defun srht-git-repo-tree (name &optional username)
"Return the tree resource for the latest commit to the default branch.
diff --git a/lisp/srht-paste.el b/lisp/srht-paste.el
index ce3ea13dfa..483842f524 100644
--- a/lisp/srht-paste.el
+++ b/lisp/srht-paste.el
@@ -28,10 +28,11 @@
(defvar srht-paste-all-pastes nil
"Stores pastes info.")
-(defun srht-paste--make-crud (path &optional body)
+(defun srht-paste--make-crud (path &optional query body)
"Make crud for paste service.
-PATH is the path for the URI. BODY is the body sent to the URI."
- (srht-generic-crud 'paste path body))
+PATH is the path for the URI. BODY is the body sent to the URI.
+QUERY is the query for the URI."
+ (srht-generic-crud 'paste path query body))
(cl-defun srht-paste-make (&key (visibility "unlisted") (filename 'null)
contents)
"Make paste parameters.
@@ -43,9 +44,10 @@ CONTENTS must be a UTF-8 encoded string; binary files are
not allowed."
(files . [((filename . ,filename)
(contents . ,contents))])))
-(defun srht-pastes ()
- "Retrieve all the pastes that belong to the user."
- (srht-paste--make-crud "/api/pastes"))
+(defun srht-pastes (&optional query)
+ "Retrieve all the pastes that belong to the user.
+QUERY is the query for the URI."
+ (srht-paste--make-crud "/api/pastes" query))
(defun srht-paste-blob (sha)
"Retrieve a blob resource with the hash SHA."
@@ -90,7 +92,7 @@ specify the DETAILS (see `srht-paste-make') of the paste."
((stringp sha)
(srht-paste--make-crud (format "/api/pastes/%s" sha)))
((stringp (plist-get details :contents))
- (srht-paste--make-crud "/api/pastes" (apply #'srht-paste-make details)))))
+ (srht-paste--make-crud "/api/pastes" nil (apply #'srht-paste-make
details)))))
(defun srht-paste--get-content ()
"Extract the content we want to paste.
diff --git a/lisp/srht.el b/lisp/srht.el
index 0aa96911d2..d35b38464c 100644
--- a/lisp/srht.el
+++ b/lisp/srht.el
@@ -138,12 +138,13 @@ fails with one argument, a `plz-error' struct."
:else else
:as as)))
-(defun srht-generic-crud (service path &optional body form)
+(defun srht-generic-crud (service path &optional query body form)
"Return a list of arguments to pass to `srht--make-crud-request'.
SERVICE is the service to used, and PATH is the path for the URI.
BODY is optional, if it is an empty list, the resulting list will not
-contain the body at all. FORM is optional."
- (let ((crud `(:service ,service :path ,path :form ,form)))
+contain the body at all. FORM is optional. QUERY is the query for the
+URI."
+ (let ((crud `(:service ,service :path ,path :query , query :form ,form)))
(if body
(append crud `(:body ,(if form body (json-encode body))))
crud)))
- [elpa] externals/srht 0db1310218 09/27: Downgrade Emacs requirements to 27.1., (continued)
- [elpa] externals/srht 0db1310218 09/27: Downgrade Emacs requirements to 27.1., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 235929a7a6 21/27: Update README., ELPA Syncer, 2022/05/17
- [elpa] externals/srht e17edd7643 04/27: Add README., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 6037d9f03c 22/27: Update README., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 3c4df2cff1 06/27: Add make rules., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 7b3792ac75 12/27: Eldev: use the path from the store for plz., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 81519fed59 15/27: Add git service bindings., ELPA Syncer, 2022/05/17
- [elpa] externals/srht a99a8e4bd1 19/27: srht-git--repo-name-read: Add doc string., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 9dd0d15e4a 20/27: srht-git-repo-update: Fix., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 0e53961bbc 27/27: srht-read-with-annotaion: Add category arg., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 0b37b7225f 24/27: Add support for pagination.,
ELPA Syncer <=
- [elpa] externals/srht f3cd7c5639 10/27: Set eldev-project-main-file., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 87ab3099b0 13/27: build: Add emacs-plz to packages., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 6f87acb901 16/27: Add commands to create, update and delete git repo., ELPA Syncer, 2022/05/17
- [elpa] externals/srht a3088beb18 18/27: srht-git-repo-update: Set initial inputs., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 0e0d56a77b 17/27: srth: srht-read-with-annotaion: Fix., ELPA Syncer, 2022/05/17
- [elpa] externals/srht e464826002 23/27: Clean up the code, enhance README, update headers for ELPA., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 764350e334 26/27: Fix test., ELPA Syncer, 2022/05/17
- [elpa] externals/srht d6393e8c31 11/27: Eldev: add load-path., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 0175b45ac1 14/27: external: Expunge., ELPA Syncer, 2022/05/17
- [elpa] externals/srht 50ad7d35bc 25/27: Update README., ELPA Syncer, 2022/05/17