← All Modules

assay.servicenow

ServiceNow Table API client plus a small CMDB helper. Client: servicenow.client(url, {user="...", password="..."}) (basic) or servicenow.client(url, {token="..."}) (bearer / OAuth).

Table API

CMDB

Mutation summary

table:create and table:update are the true mutations. cmdb:query is a read that happens to use POST. All three route through the already-gated http.post / http.patch verbs.

Example:

local servicenow = require("assay.servicenow")
local c = servicenow.client("https://example.service-now.com", {
  user = env.get("SNOW_USER"),
  password = env.get("SNOW_PASSWORD"),
})

local rows = c.table:list("incident", { query = "active=true", limit = 10, fields = { "number", "state" } })
for _, r in ipairs(rows) do
  print(r.number, r.state)
end

local created = c.table:create("incident", { short_description = "disk pressure on app-1" })
c.table:update("incident", created.sys_id, { state = "6" })

local servers = c.cmdb:query("cmdb_ci_server", { sysparm_query = "nameLIKEapp" })