From 9f842a764a949944e1f32748253b8565b17192de Mon Sep 17 00:00:00 2001 From: Jonathan Carroll Otsuka Date: Thu, 26 Sep 2024 20:09:02 -0500 Subject: [PATCH] Adding `jiralib-get-labels` This functions gets all available labels. So we can later use them to assign to during our jira create issue workflow. --- jiralib.el | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/jiralib.el b/jiralib.el index 4c1907b..de116d2 100644 --- a/jiralib.el +++ b/jiralib.el @@ -472,7 +472,8 @@ request.el, so if at all possible, it should be avoided." ('updateIssue (jiralib--rest-call-it (format "/rest/api/2/issue/%s" (first params)) :type "PUT" - :data (json-encode `((fields . ,(second params))))))))) + :data (json-encode `((fields . ,(second params)))))) + ('getLabels (jiralib--rest-call-it (format "/rest/api/2/label?startAt=%s" (first params))))))) (defun jiralib--soap-call-it (&rest args) "Deprecated SOAP call endpoint. Will be removed soon. @@ -1202,6 +1203,20 @@ Auxiliary Notes: (apply 'jiralib-call "getIssuesFromBoard" (cl-getf params :callback) board-id params)) +(defvar jiralib-labels-cache nil) +(defun jiralib-get-labels () + "Return assignable labels that can be added to an issue." + (unless jiralib-labels-cache + (setq jiralib-labels-start-at 0) + (while (progn + (let* ((labels (jiralib-call "getLabels" nil jiralib-labels-start-at)) + (max-results (alist-get 'maxResults labels)) + (is-last (alist-get 'isLast labels)) + (values (alist-get 'values labels))) + (setq jiralib-labels-start-at (+ max-results jiralib-labels-start-at) + jiralib-labels-cache (append values jiralib-labels-cache)) + (not (eq is-last t))))))) + (defun jiralib--agile-not-last-entry (num-entries total start-at limit) "Return true if need to retrieve next page from agile api" (and (> num-entries 0)