feat(sailpoint): new SailPoint IdentityNow IGA integration
IdentityNow API v3, 6 commands: list/get identities, list accounts, disable/ enable account (containment). OAuth2 client-credentials auth, stdlib-only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,81 @@
|
|||||||
|
id: sailpoint
|
||||||
|
name: SailPoint IdentityNow
|
||||||
|
version: 1.0.0
|
||||||
|
description: "SailPoint IdentityNow (API v3) — identity governance and containment: list and read identities, list accounts, and disable/enable an account. OAuth2 client-credentials authentication; stdlib-only, no extra Python dependencies."
|
||||||
|
changelog: "1.0.0 — Initial release: list/get identities, list accounts, disable/enable account."
|
||||||
|
category: identity
|
||||||
|
|
||||||
|
# Per-instance configuration. Client credentials are exchanged for a bearer
|
||||||
|
# token at {base_url}/oauth/token; API calls go to {base_url}/v3.
|
||||||
|
config_schema:
|
||||||
|
properties:
|
||||||
|
base_url:
|
||||||
|
type: string
|
||||||
|
description: "IdentityNow API URL (e.g. https://tenant.api.identitynow.com)"
|
||||||
|
client_id:
|
||||||
|
type: string
|
||||||
|
description: "OAuth client ID"
|
||||||
|
client_secret:
|
||||||
|
type: string
|
||||||
|
description: "OAuth client secret"
|
||||||
|
x-soar-sensitive: true
|
||||||
|
required:
|
||||||
|
- base_url
|
||||||
|
- client_id
|
||||||
|
- client_secret
|
||||||
|
|
||||||
|
commands:
|
||||||
|
- id: list_identities
|
||||||
|
name: sailpoint-list-identities
|
||||||
|
description: "List identities (optionally filtered)."
|
||||||
|
risk: read
|
||||||
|
inputs_schema:
|
||||||
|
properties:
|
||||||
|
filters: { type: string, description: "Filter expression (e.g. name eq \"john.doe\")" }
|
||||||
|
limit: { type: number, description: "Max identities (default 50)" }
|
||||||
|
required: []
|
||||||
|
outputs_schema: { properties: {} }
|
||||||
|
- id: get_identity
|
||||||
|
name: sailpoint-get-identity
|
||||||
|
description: "Get a single identity by ID."
|
||||||
|
risk: read
|
||||||
|
inputs_schema:
|
||||||
|
properties:
|
||||||
|
identity_id: { type: string, description: "Identity ID" }
|
||||||
|
required: [identity_id]
|
||||||
|
outputs_schema: { properties: {} }
|
||||||
|
- id: list_accounts
|
||||||
|
name: sailpoint-list-accounts
|
||||||
|
description: "List accounts (optionally filtered)."
|
||||||
|
risk: read
|
||||||
|
inputs_schema:
|
||||||
|
properties:
|
||||||
|
filters: { type: string, description: "Filter expression (e.g. identityId eq \"...\")" }
|
||||||
|
limit: { type: number, description: "Max accounts (default 50)" }
|
||||||
|
required: []
|
||||||
|
outputs_schema: { properties: {} }
|
||||||
|
- id: disable_account
|
||||||
|
name: sailpoint-disable-account
|
||||||
|
description: "Disable an account (containment)."
|
||||||
|
inputs_schema:
|
||||||
|
properties:
|
||||||
|
account_id: { type: string, description: "Account ID" }
|
||||||
|
required: [account_id]
|
||||||
|
outputs_schema: { properties: {} }
|
||||||
|
- id: enable_account
|
||||||
|
name: sailpoint-enable-account
|
||||||
|
description: "Enable an account."
|
||||||
|
inputs_schema:
|
||||||
|
properties:
|
||||||
|
account_id: { type: string, description: "Account ID" }
|
||||||
|
required: [account_id]
|
||||||
|
outputs_schema: { properties: {} }
|
||||||
|
|
||||||
|
- id: test_connection
|
||||||
|
name: sailpoint-test-connection
|
||||||
|
description: "Verify credentials via the token exchange (used by the Test button)."
|
||||||
|
risk: read
|
||||||
|
inputs_schema:
|
||||||
|
properties: {}
|
||||||
|
required: []
|
||||||
|
outputs_schema: { properties: {} }
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||||
|
|
||||||
|
|
||||||
|
def _cfg():
|
||||||
|
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||||
|
|
||||||
|
|
||||||
|
def _inputs():
|
||||||
|
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||||
|
|
||||||
|
|
||||||
|
def _base(cfg):
|
||||||
|
return str(cfg.get("base_url", "")).rstrip("/")
|
||||||
|
|
||||||
|
|
||||||
|
def _token(cfg):
|
||||||
|
form = urllib.parse.urlencode({
|
||||||
|
"grant_type": "client_credentials",
|
||||||
|
"client_id": str(cfg.get("client_id", "")),
|
||||||
|
"client_secret": str(cfg.get("client_secret", "")),
|
||||||
|
}).encode("utf-8")
|
||||||
|
req = urllib.request.Request(_base(cfg) + "/oauth/token", data=form,
|
||||||
|
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
"Accept": "application/json"}, method="POST")
|
||||||
|
with urllib.request.urlopen(req, timeout=60) as r:
|
||||||
|
tok = json.loads(r.read())
|
||||||
|
if not tok.get("access_token"):
|
||||||
|
raise Exception("Token request failed: " + json.dumps(tok))
|
||||||
|
return tok["access_token"]
|
||||||
|
|
||||||
|
|
||||||
|
def request(method, path, cfg, token, body=None, params=None):
|
||||||
|
url = _base(cfg) + "/v3" + path
|
||||||
|
if params:
|
||||||
|
clean = {k: v for k, v in params.items() if v not in (None, "")}
|
||||||
|
if clean:
|
||||||
|
url += "?" + urllib.parse.urlencode(clean)
|
||||||
|
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||||
|
headers = {"Authorization": "Bearer " + token, "Accept": "application/json"}
|
||||||
|
if data is not None:
|
||||||
|
headers["Content-Type"] = "application/json"
|
||||||
|
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||||
|
with urllib.request.urlopen(req, timeout=60) as r:
|
||||||
|
raw = r.read()
|
||||||
|
return json.loads(raw) if raw else {}
|
||||||
|
|
||||||
|
|
||||||
|
def _run(fn):
|
||||||
|
try:
|
||||||
|
cfg = _cfg()
|
||||||
|
inputs = _inputs()
|
||||||
|
token = _token(cfg)
|
||||||
|
print(json.dumps(fn(cfg, token, inputs)))
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||||
|
sys.exit(1)
|
||||||
|
except Exception as e:
|
||||||
|
print(json.dumps({"error": str(e)}))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||||
|
|
||||||
|
|
||||||
|
def main(cfg, token, inputs):
|
||||||
|
account_id = inputs.get("account_id")
|
||||||
|
if not account_id:
|
||||||
|
raise Exception("account_id is required")
|
||||||
|
resp = request("POST", "/accounts/" + q(account_id) + "/disable", cfg, token,
|
||||||
|
body={"externalVerificationId": None, "forceProvisioning": False})
|
||||||
|
if not resp:
|
||||||
|
return {"ok": True, "account_id": account_id, "action": "disable"}
|
||||||
|
return resp
|
||||||
|
|
||||||
|
|
||||||
|
_run(main)
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||||
|
|
||||||
|
|
||||||
|
def _cfg():
|
||||||
|
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||||
|
|
||||||
|
|
||||||
|
def _inputs():
|
||||||
|
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||||
|
|
||||||
|
|
||||||
|
def _base(cfg):
|
||||||
|
return str(cfg.get("base_url", "")).rstrip("/")
|
||||||
|
|
||||||
|
|
||||||
|
def _token(cfg):
|
||||||
|
form = urllib.parse.urlencode({
|
||||||
|
"grant_type": "client_credentials",
|
||||||
|
"client_id": str(cfg.get("client_id", "")),
|
||||||
|
"client_secret": str(cfg.get("client_secret", "")),
|
||||||
|
}).encode("utf-8")
|
||||||
|
req = urllib.request.Request(_base(cfg) + "/oauth/token", data=form,
|
||||||
|
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
"Accept": "application/json"}, method="POST")
|
||||||
|
with urllib.request.urlopen(req, timeout=60) as r:
|
||||||
|
tok = json.loads(r.read())
|
||||||
|
if not tok.get("access_token"):
|
||||||
|
raise Exception("Token request failed: " + json.dumps(tok))
|
||||||
|
return tok["access_token"]
|
||||||
|
|
||||||
|
|
||||||
|
def request(method, path, cfg, token, body=None, params=None):
|
||||||
|
url = _base(cfg) + "/v3" + path
|
||||||
|
if params:
|
||||||
|
clean = {k: v for k, v in params.items() if v not in (None, "")}
|
||||||
|
if clean:
|
||||||
|
url += "?" + urllib.parse.urlencode(clean)
|
||||||
|
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||||
|
headers = {"Authorization": "Bearer " + token, "Accept": "application/json"}
|
||||||
|
if data is not None:
|
||||||
|
headers["Content-Type"] = "application/json"
|
||||||
|
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||||
|
with urllib.request.urlopen(req, timeout=60) as r:
|
||||||
|
raw = r.read()
|
||||||
|
return json.loads(raw) if raw else {}
|
||||||
|
|
||||||
|
|
||||||
|
def _run(fn):
|
||||||
|
try:
|
||||||
|
cfg = _cfg()
|
||||||
|
inputs = _inputs()
|
||||||
|
token = _token(cfg)
|
||||||
|
print(json.dumps(fn(cfg, token, inputs)))
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||||
|
sys.exit(1)
|
||||||
|
except Exception as e:
|
||||||
|
print(json.dumps({"error": str(e)}))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||||
|
|
||||||
|
|
||||||
|
def main(cfg, token, inputs):
|
||||||
|
account_id = inputs.get("account_id")
|
||||||
|
if not account_id:
|
||||||
|
raise Exception("account_id is required")
|
||||||
|
resp = request("POST", "/accounts/" + q(account_id) + "/enable", cfg, token,
|
||||||
|
body={"forceProvisioning": False})
|
||||||
|
if not resp:
|
||||||
|
return {"ok": True, "account_id": account_id, "action": "enable"}
|
||||||
|
return resp
|
||||||
|
|
||||||
|
|
||||||
|
_run(main)
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||||
|
|
||||||
|
|
||||||
|
def _cfg():
|
||||||
|
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||||
|
|
||||||
|
|
||||||
|
def _inputs():
|
||||||
|
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||||
|
|
||||||
|
|
||||||
|
def _base(cfg):
|
||||||
|
return str(cfg.get("base_url", "")).rstrip("/")
|
||||||
|
|
||||||
|
|
||||||
|
def _token(cfg):
|
||||||
|
form = urllib.parse.urlencode({
|
||||||
|
"grant_type": "client_credentials",
|
||||||
|
"client_id": str(cfg.get("client_id", "")),
|
||||||
|
"client_secret": str(cfg.get("client_secret", "")),
|
||||||
|
}).encode("utf-8")
|
||||||
|
req = urllib.request.Request(_base(cfg) + "/oauth/token", data=form,
|
||||||
|
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
"Accept": "application/json"}, method="POST")
|
||||||
|
with urllib.request.urlopen(req, timeout=60) as r:
|
||||||
|
tok = json.loads(r.read())
|
||||||
|
if not tok.get("access_token"):
|
||||||
|
raise Exception("Token request failed: " + json.dumps(tok))
|
||||||
|
return tok["access_token"]
|
||||||
|
|
||||||
|
|
||||||
|
def request(method, path, cfg, token, body=None, params=None):
|
||||||
|
url = _base(cfg) + "/v3" + path
|
||||||
|
if params:
|
||||||
|
clean = {k: v for k, v in params.items() if v not in (None, "")}
|
||||||
|
if clean:
|
||||||
|
url += "?" + urllib.parse.urlencode(clean)
|
||||||
|
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||||
|
headers = {"Authorization": "Bearer " + token, "Accept": "application/json"}
|
||||||
|
if data is not None:
|
||||||
|
headers["Content-Type"] = "application/json"
|
||||||
|
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||||
|
with urllib.request.urlopen(req, timeout=60) as r:
|
||||||
|
raw = r.read()
|
||||||
|
return json.loads(raw) if raw else {}
|
||||||
|
|
||||||
|
|
||||||
|
def _run(fn):
|
||||||
|
try:
|
||||||
|
cfg = _cfg()
|
||||||
|
inputs = _inputs()
|
||||||
|
token = _token(cfg)
|
||||||
|
print(json.dumps(fn(cfg, token, inputs)))
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||||
|
sys.exit(1)
|
||||||
|
except Exception as e:
|
||||||
|
print(json.dumps({"error": str(e)}))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||||
|
|
||||||
|
|
||||||
|
def main(cfg, token, inputs):
|
||||||
|
identity_id = inputs.get("identity_id")
|
||||||
|
if not identity_id:
|
||||||
|
raise Exception("identity_id is required")
|
||||||
|
return request("GET", "/identities/" + q(identity_id), cfg, token)
|
||||||
|
|
||||||
|
|
||||||
|
_run(main)
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||||
|
|
||||||
|
|
||||||
|
def _cfg():
|
||||||
|
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||||
|
|
||||||
|
|
||||||
|
def _inputs():
|
||||||
|
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||||
|
|
||||||
|
|
||||||
|
def _base(cfg):
|
||||||
|
return str(cfg.get("base_url", "")).rstrip("/")
|
||||||
|
|
||||||
|
|
||||||
|
def _token(cfg):
|
||||||
|
form = urllib.parse.urlencode({
|
||||||
|
"grant_type": "client_credentials",
|
||||||
|
"client_id": str(cfg.get("client_id", "")),
|
||||||
|
"client_secret": str(cfg.get("client_secret", "")),
|
||||||
|
}).encode("utf-8")
|
||||||
|
req = urllib.request.Request(_base(cfg) + "/oauth/token", data=form,
|
||||||
|
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
"Accept": "application/json"}, method="POST")
|
||||||
|
with urllib.request.urlopen(req, timeout=60) as r:
|
||||||
|
tok = json.loads(r.read())
|
||||||
|
if not tok.get("access_token"):
|
||||||
|
raise Exception("Token request failed: " + json.dumps(tok))
|
||||||
|
return tok["access_token"]
|
||||||
|
|
||||||
|
|
||||||
|
def request(method, path, cfg, token, body=None, params=None):
|
||||||
|
url = _base(cfg) + "/v3" + path
|
||||||
|
if params:
|
||||||
|
clean = {k: v for k, v in params.items() if v not in (None, "")}
|
||||||
|
if clean:
|
||||||
|
url += "?" + urllib.parse.urlencode(clean)
|
||||||
|
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||||
|
headers = {"Authorization": "Bearer " + token, "Accept": "application/json"}
|
||||||
|
if data is not None:
|
||||||
|
headers["Content-Type"] = "application/json"
|
||||||
|
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||||
|
with urllib.request.urlopen(req, timeout=60) as r:
|
||||||
|
raw = r.read()
|
||||||
|
return json.loads(raw) if raw else {}
|
||||||
|
|
||||||
|
|
||||||
|
def _run(fn):
|
||||||
|
try:
|
||||||
|
cfg = _cfg()
|
||||||
|
inputs = _inputs()
|
||||||
|
token = _token(cfg)
|
||||||
|
print(json.dumps(fn(cfg, token, inputs)))
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||||
|
sys.exit(1)
|
||||||
|
except Exception as e:
|
||||||
|
print(json.dumps({"error": str(e)}))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def main(cfg, token, inputs):
|
||||||
|
filters = inputs.get("filters")
|
||||||
|
limit = inputs.get("limit")
|
||||||
|
return request("GET", "/accounts", cfg, token, params={"filters": filters, "limit": int(limit or 50)})
|
||||||
|
|
||||||
|
|
||||||
|
_run(main)
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||||
|
|
||||||
|
|
||||||
|
def _cfg():
|
||||||
|
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||||
|
|
||||||
|
|
||||||
|
def _inputs():
|
||||||
|
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||||
|
|
||||||
|
|
||||||
|
def _base(cfg):
|
||||||
|
return str(cfg.get("base_url", "")).rstrip("/")
|
||||||
|
|
||||||
|
|
||||||
|
def _token(cfg):
|
||||||
|
form = urllib.parse.urlencode({
|
||||||
|
"grant_type": "client_credentials",
|
||||||
|
"client_id": str(cfg.get("client_id", "")),
|
||||||
|
"client_secret": str(cfg.get("client_secret", "")),
|
||||||
|
}).encode("utf-8")
|
||||||
|
req = urllib.request.Request(_base(cfg) + "/oauth/token", data=form,
|
||||||
|
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
"Accept": "application/json"}, method="POST")
|
||||||
|
with urllib.request.urlopen(req, timeout=60) as r:
|
||||||
|
tok = json.loads(r.read())
|
||||||
|
if not tok.get("access_token"):
|
||||||
|
raise Exception("Token request failed: " + json.dumps(tok))
|
||||||
|
return tok["access_token"]
|
||||||
|
|
||||||
|
|
||||||
|
def request(method, path, cfg, token, body=None, params=None):
|
||||||
|
url = _base(cfg) + "/v3" + path
|
||||||
|
if params:
|
||||||
|
clean = {k: v for k, v in params.items() if v not in (None, "")}
|
||||||
|
if clean:
|
||||||
|
url += "?" + urllib.parse.urlencode(clean)
|
||||||
|
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||||
|
headers = {"Authorization": "Bearer " + token, "Accept": "application/json"}
|
||||||
|
if data is not None:
|
||||||
|
headers["Content-Type"] = "application/json"
|
||||||
|
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||||
|
with urllib.request.urlopen(req, timeout=60) as r:
|
||||||
|
raw = r.read()
|
||||||
|
return json.loads(raw) if raw else {}
|
||||||
|
|
||||||
|
|
||||||
|
def _run(fn):
|
||||||
|
try:
|
||||||
|
cfg = _cfg()
|
||||||
|
inputs = _inputs()
|
||||||
|
token = _token(cfg)
|
||||||
|
print(json.dumps(fn(cfg, token, inputs)))
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||||
|
sys.exit(1)
|
||||||
|
except Exception as e:
|
||||||
|
print(json.dumps({"error": str(e)}))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def main(cfg, token, inputs):
|
||||||
|
filters = inputs.get("filters")
|
||||||
|
limit = inputs.get("limit")
|
||||||
|
return request("GET", "/public-identities", cfg, token, params={"filters": filters, "limit": int(limit or 50)})
|
||||||
|
|
||||||
|
|
||||||
|
_run(main)
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||||
|
|
||||||
|
|
||||||
|
def _cfg():
|
||||||
|
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||||
|
|
||||||
|
|
||||||
|
def _inputs():
|
||||||
|
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||||
|
|
||||||
|
|
||||||
|
def _base(cfg):
|
||||||
|
return str(cfg.get("base_url", "")).rstrip("/")
|
||||||
|
|
||||||
|
|
||||||
|
def _token(cfg):
|
||||||
|
form = urllib.parse.urlencode({
|
||||||
|
"grant_type": "client_credentials",
|
||||||
|
"client_id": str(cfg.get("client_id", "")),
|
||||||
|
"client_secret": str(cfg.get("client_secret", "")),
|
||||||
|
}).encode("utf-8")
|
||||||
|
req = urllib.request.Request(_base(cfg) + "/oauth/token", data=form,
|
||||||
|
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
"Accept": "application/json"}, method="POST")
|
||||||
|
with urllib.request.urlopen(req, timeout=60) as r:
|
||||||
|
tok = json.loads(r.read())
|
||||||
|
if not tok.get("access_token"):
|
||||||
|
raise Exception("Token request failed: " + json.dumps(tok))
|
||||||
|
return tok["access_token"]
|
||||||
|
|
||||||
|
|
||||||
|
def request(method, path, cfg, token, body=None, params=None):
|
||||||
|
url = _base(cfg) + "/v3" + path
|
||||||
|
if params:
|
||||||
|
clean = {k: v for k, v in params.items() if v not in (None, "")}
|
||||||
|
if clean:
|
||||||
|
url += "?" + urllib.parse.urlencode(clean)
|
||||||
|
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||||
|
headers = {"Authorization": "Bearer " + token, "Accept": "application/json"}
|
||||||
|
if data is not None:
|
||||||
|
headers["Content-Type"] = "application/json"
|
||||||
|
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||||
|
with urllib.request.urlopen(req, timeout=60) as r:
|
||||||
|
raw = r.read()
|
||||||
|
return json.loads(raw) if raw else {}
|
||||||
|
|
||||||
|
|
||||||
|
def _run(fn):
|
||||||
|
try:
|
||||||
|
cfg = _cfg()
|
||||||
|
inputs = _inputs()
|
||||||
|
token = _token(cfg)
|
||||||
|
print(json.dumps(fn(cfg, token, inputs)))
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||||
|
sys.exit(1)
|
||||||
|
except Exception as e:
|
||||||
|
print(json.dumps({"error": str(e)}))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def main(cfg, token, inputs):
|
||||||
|
request("GET", "/public-identities", cfg, token, params={"limit": 1})
|
||||||
|
return {"ok": True}
|
||||||
|
|
||||||
|
|
||||||
|
_run(main)
|
||||||
Reference in New Issue
Block a user