Preview:
package policy

default allow = false

user_shifts_api_endpoint = sprintf("http://user-shifts-api:8081/api/v1/userShifts/%v", [input.user.userId])

headers = {
   "Content-Type": "application/json",
   "Accept": "application/json"
}

available_shifts = http.send(
 {
 "method": "get",
 "url": user_shifts_api_endpoint,
 "headers": headers
 }
)
response = available_shifts
allow {
   some i
   shiftStart = time.parse_rfc3339_ns(response[i].shiftStart)
   shiftEnd = time.parse_rfc3339_ns(response[i].shiftEnd)
   now = time.now_ns()

   shiftStart <= now
   now < shiftEnd
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter