Functions that wrap Jira API.
Every Jira function in this namespace follows the same pattern and
accepts at least the following three parameters: send-fn
,
receive-fn
, and opts
.
send-fn
. A function of one argument, that accepts a Ring-style
request map, sends it to a Jira HTTP server and returns
a Ring-style response map.receive-fn
. A function of one argument, that accepts a Ring-style
response map, transforms it and returns the transformed value.opts
. A map (it is optional for some of the functions) that configures
a Jira query.The library doesn't send HTTP requests itself, delegating this job
to a caller via send-fn
and receive-fn
parameters instead. Each
function will invoke send-fn
argument with a request map it
generated, then return a result of applying receive-fn
to the
return value from send-fn
:
(defn typical-function
[send-fn receive-fn opts]
(let [request (generate-request-map opts)]
(-> request
send-fn
receive-fn)))
This approach allows for zero dependencies library but it comes with
a price - users have to add a glue between HTTP library of their
choice and manenko/clj-jira
.
This section explains how to use manenko/clj-jira
and clj-http
libraries together.
First, require both libraries in your application:
(ns manenko.clj-jira.example
(:require [clj-http.client :as client]
[manenko.clj-jira.core :as jira]
[manenko.clj-jira.middleware :as middleware]))
Then, define a host, email, and API token for Jira communication:
(def host "example.atlassian.net")
(def email "user@example.com")
(def token "DN21KLJh298haishu8AUHIU3")
You can, of course, retrieve them from other sources instead of hardcoding.
Next step is to define a function that sends an HTTP request and
integrate it with Jira middleware provided by manenko/clj-jira
:
(defn request
[m]
(client/with-middleware
(conj
client/default-middleware
(middleware/wrap-api host)
(middleware/wrap-token-auth email token))
(client/request m)))
Now you can use request
function to make API calls:
(jira/get-current-user request identity)
Functions that wrap Jira API. ### Design Every Jira function in this namespace follows the same pattern and accepts at least the following three parameters: `send-fn`, `receive-fn`, and `opts`. * `send-fn`. A function of one argument, that accepts a [Ring-style] *request* map, sends it to a Jira HTTP server and returns a [Ring-style] *response* map. * `receive-fn`. A function of one argument, that accepts a [Ring-style] *response* map, transforms it and returns the *transformed* value. * `opts`. A map (it is optional for some of the functions) that configures a Jira query. The library doesn't send HTTP requests itself, delegating this job to a caller via `send-fn` and `receive-fn` parameters instead. Each function will invoke `send-fn` argument with a request map it generated, then return a result of applying `receive-fn` to the return value from `send-fn`: ```clojure (defn typical-function [send-fn receive-fn opts] (let [request (generate-request-map opts)] (-> request send-fn receive-fn))) ``` This approach allows for zero dependencies library but it comes with a price - users have to add a glue between HTTP library of their choice and `manenko/clj-jira`. ### Quickstart This section explains how to use `manenko/clj-jira` and [clj-http] libraries together. First, require both libraries in your application: ```clojure (ns manenko.clj-jira.example (:require [clj-http.client :as client] [manenko.clj-jira.core :as jira] [manenko.clj-jira.middleware :as middleware])) ``` Then, define a host, email, and [API token] for Jira communication: ```clojure (def host "example.atlassian.net") (def email "user@example.com") (def token "DN21KLJh298haishu8AUHIU3") ``` You can, of course, retrieve them from other sources instead of hardcoding. Next step is to define a function that sends an HTTP request and integrate it with Jira middleware provided by `manenko/clj-jira`: ```clojure (defn request [m] (client/with-middleware (conj client/default-middleware (middleware/wrap-api host) (middleware/wrap-token-auth email token)) (client/request m))) ``` Now you can use `request` function to make API calls: ```clojure (jira/get-current-user request identity) ``` [clj-http]: https://github.com/dakrone/clj-http [Ring-style]: https://github.com/ring-clojure/ring/blob/master/SPEC [API token]: https://confluence.atlassian.com/cloud/api-tokens-938839638.html
Ring-style middleware for Jira REST API requests.
Ring-style middleware for Jira REST API requests.
Functions that generate ring-style request maps for Jira REST API.
Functions that generate ring-style request maps for Jira REST API.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close