Compare commits

...

3 Commits

Author SHA1 Message Date
Guillaume BOURGEOIS 82353947d6 feat(mailinblack): new Mailinblack email-security integration (French vendor)
Mailinblack API, 5 commands: list quarantine, release message, block/allow
sender. Bearer auth, stdlib-only. py_compile clean. NOTE: API paths best-effort
— verify against vendor docs before production.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 21:37:32 +02:00
Guillaume BOURGEOIS ac47315b30 feat(cybelangel): new CybelAngel attack-surface integration (French vendor)
CybelAngel platform API, 4 commands: list/get reports, update report status.
OAuth2 client-credentials auth, stdlib-only. py_compile clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 21:37:31 +02:00
Guillaume BOURGEOIS 631292fcc7 feat(scaleway): new Scaleway cloud integration (French vendor)
Scaleway Cloud API, 5 commands: list/get instances, list security groups, list
projects. Secret-key (X-Auth-Token) auth, stdlib-only. py_compile clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 21:37:31 +02:00
17 changed files with 983 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
id: cybelangel
name: CybelAngel
version: 1.0.0
description: "CybelAngel (External Attack Surface / data-leak detection API) — read exposure reports: list reports, get a report, and update a report's status. OAuth2 client-credentials authentication; stdlib-only, no extra Python dependencies. (French vendor.)"
changelog: "1.0.0 — Initial release: list/get reports, update report status."
category: threat_intel
# Per-instance configuration. Client credentials are exchanged for a bearer
# token at the auth endpoint; API calls go to the platform API.
config_schema:
properties:
auth_url:
type: string
description: "Token URL"
default: "https://auth.cybelangel.com/oauth/token"
api_url:
type: string
description: "Platform API URL"
default: "https://platform.cybelangel.com"
client_id:
type: string
description: "API client ID"
client_secret:
type: string
description: "API client secret"
x-soar-sensitive: true
required:
- client_id
- client_secret
commands:
- id: list_reports
name: cybelangel-list-reports
description: "List exposure reports."
risk: read
inputs_schema:
properties:
status: { type: string, description: "Optional status filter (open, resolved, discarded)" }
required: []
outputs_schema: { properties: {} }
- id: get_report
name: cybelangel-get-report
description: "Get a single report by ID."
risk: read
inputs_schema:
properties:
report_id: { type: string, description: "Report ID" }
required: [report_id]
outputs_schema: { properties: {} }
- id: update_report_status
name: cybelangel-update-report-status
description: "Update a report's status."
inputs_schema:
properties:
report_id: { type: string, description: "Report ID" }
status: { type: string, description: "New status (open, resolved, discarded)" }
required: [report_id, status]
outputs_schema: { properties: {} }
- id: test_connection
name: cybelangel-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,74 @@
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 _api(cfg):
return (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/api/v2"
def _token(cfg):
auth_url = str(cfg.get("auth_url") or "https://auth.cybelangel.com/oauth/token")
api = (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/"
body = json.dumps({
"grant_type": "client_credentials",
"client_id": str(cfg.get("client_id", "")),
"client_secret": str(cfg.get("client_secret", "")),
"audience": api,
}).encode("utf-8")
req = urllib.request.Request(auth_url, data=body,
headers={"Content-Type": "application/json", "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 = _api(cfg) + 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):
report_id = inputs.get("report_id")
if not report_id:
raise Exception("report_id is required")
return request("GET", "/reports/" + q(report_id), cfg, token)
_run(main)
@@ -0,0 +1,69 @@
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 _api(cfg):
return (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/api/v2"
def _token(cfg):
auth_url = str(cfg.get("auth_url") or "https://auth.cybelangel.com/oauth/token")
api = (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/"
body = json.dumps({
"grant_type": "client_credentials",
"client_id": str(cfg.get("client_id", "")),
"client_secret": str(cfg.get("client_secret", "")),
"audience": api,
}).encode("utf-8")
req = urllib.request.Request(auth_url, data=body,
headers={"Content-Type": "application/json", "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 = _api(cfg) + 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):
status = inputs.get("status")
return request("GET", "/reports", cfg, token, params={"status": status})
_run(main)
@@ -0,0 +1,69 @@
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 _api(cfg):
return (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/api/v2"
def _token(cfg):
auth_url = str(cfg.get("auth_url") or "https://auth.cybelangel.com/oauth/token")
api = (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/"
body = json.dumps({
"grant_type": "client_credentials",
"client_id": str(cfg.get("client_id", "")),
"client_secret": str(cfg.get("client_secret", "")),
"audience": api,
}).encode("utf-8")
req = urllib.request.Request(auth_url, data=body,
headers={"Content-Type": "application/json", "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 = _api(cfg) + 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", "/reports", cfg, token, params={"limit": 1})
return {"ok": True}
_run(main)
@@ -0,0 +1,80 @@
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 _api(cfg):
return (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/api/v2"
def _token(cfg):
auth_url = str(cfg.get("auth_url") or "https://auth.cybelangel.com/oauth/token")
api = (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/"
body = json.dumps({
"grant_type": "client_credentials",
"client_id": str(cfg.get("client_id", "")),
"client_secret": str(cfg.get("client_secret", "")),
"audience": api,
}).encode("utf-8")
req = urllib.request.Request(auth_url, data=body,
headers={"Content-Type": "application/json", "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 = _api(cfg) + 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):
report_id = inputs.get("report_id")
status = inputs.get("status")
if not report_id:
raise Exception("report_id is required")
if not status:
raise Exception("status is required")
resp = request("PUT", "/reports/" + q(report_id) + "/status", cfg, token, body={"status": status})
if not resp:
return {"ok": True, "report_id": report_id, "status": status}
return resp
_run(main)
+65
View File
@@ -0,0 +1,65 @@
id: mailinblack
name: Mailinblack
version: 1.0.0
description: "Mailinblack (email protection API) — anti-phishing operations: list quarantined messages, release a message, and manage sender allow/block lists. Bearer-token authentication; stdlib-only, no extra Python dependencies. (French vendor. NOTE: exact API paths are best-effort — verify against the Mailinblack API documentation before production use.)"
changelog: "1.0.0 — Initial release: list quarantine, release message, block/allow sender."
category: email
# Per-instance configuration. Auth header 'Authorization: Bearer <api_token>'.
config_schema:
properties:
base_url:
type: string
description: "Mailinblack API base URL"
api_token:
type: string
description: "API token"
x-soar-sensitive: true
required:
- base_url
- api_token
commands:
- id: list_quarantine
name: mailinblack-list-quarantine
description: "List quarantined messages."
risk: read
inputs_schema:
properties:
recipient: { type: string, description: "Optional recipient filter" }
limit: { type: number, description: "Max messages (default 25)" }
required: []
outputs_schema: { properties: {} }
- id: release_message
name: mailinblack-release-message
description: "Release a quarantined message for delivery."
inputs_schema:
properties:
message_id: { type: string, description: "Message ID" }
required: [message_id]
outputs_schema: { properties: {} }
- id: block_sender
name: mailinblack-block-sender
description: "Add a sender to the block list."
inputs_schema:
properties:
sender: { type: string, description: "Sender address to block" }
required: [sender]
outputs_schema: { properties: {} }
- id: allow_sender
name: mailinblack-allow-sender
description: "Add a sender to the allow list."
inputs_schema:
properties:
sender: { type: string, description: "Sender address to allow" }
required: [sender]
outputs_schema: { properties: {} }
- id: test_connection
name: mailinblack-test-connection
description: "Verify the API token (used by the Test button)."
risk: read
inputs_schema:
properties: {}
required: []
outputs_schema: { properties: {} }
@@ -0,0 +1,49 @@
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 request(method, path, cfg, body=None, params=None):
url = str(cfg.get("base_url", "")).rstrip("/") + 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 " + str(cfg.get("api_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:
print(json.dumps(fn(_cfg(), _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, inputs):
sender = inputs.get("sender")
if not sender:
raise Exception("sender is required")
result = request("POST", "/senders/allow", cfg, body={"sender": sender})
if not result:
return {"ok": True, "sender": sender, "action": "allow"}
return result
_run(main)
@@ -0,0 +1,49 @@
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 request(method, path, cfg, body=None, params=None):
url = str(cfg.get("base_url", "")).rstrip("/") + 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 " + str(cfg.get("api_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:
print(json.dumps(fn(_cfg(), _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, inputs):
sender = inputs.get("sender")
if not sender:
raise Exception("sender is required")
result = request("POST", "/senders/block", cfg, body={"sender": sender})
if not result:
return {"ok": True, "sender": sender, "action": "block"}
return result
_run(main)
@@ -0,0 +1,46 @@
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 request(method, path, cfg, body=None, params=None):
url = str(cfg.get("base_url", "")).rstrip("/") + 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 " + str(cfg.get("api_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:
print(json.dumps(fn(_cfg(), _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, inputs):
recipient = inputs.get("recipient")
limit = inputs.get("limit")
limit = int(limit) if limit not in (None, "") else 25
return request("GET", "/quarantine", cfg, params={"recipient": recipient, "limit": limit})
_run(main)
@@ -0,0 +1,52 @@
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 request(method, path, cfg, body=None, params=None):
url = str(cfg.get("base_url", "")).rstrip("/") + 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 " + str(cfg.get("api_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:
print(json.dumps(fn(_cfg(), _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, inputs):
message_id = inputs.get("message_id")
if not message_id:
raise Exception("message_id is required")
result = request("POST", "/quarantine/" + q(message_id) + "/release", cfg, body={})
if not result:
return {"ok": True, "message_id": message_id, "action": "release"}
return result
_run(main)
@@ -0,0 +1,44 @@
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 request(method, path, cfg, body=None, params=None):
url = str(cfg.get("base_url", "")).rstrip("/") + 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 " + str(cfg.get("api_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:
print(json.dumps(fn(_cfg(), _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, inputs):
request("GET", "/quarantine", cfg, params={"limit": 1})
return {"ok": True}
_run(main)
+67
View File
@@ -0,0 +1,67 @@
id: scaleway
name: Scaleway
version: 1.0.0
description: "Scaleway (Cloud API) — cloud inventory and visibility: list and read instances, list security groups, and list projects. Secret-key authentication; stdlib-only, no extra Python dependencies. (French vendor.)"
changelog: "1.0.0 — Initial release: list/get instances, list security groups, list projects."
category: cloud
# Per-instance configuration. Auth header 'X-Auth-Token: <secret_key>'.
config_schema:
properties:
secret_key:
type: string
description: "Scaleway API secret key"
x-soar-sensitive: true
default_zone:
type: string
description: "Default zone (e.g. fr-par-1)"
default: "fr-par-1"
required:
- secret_key
commands:
- id: list_instances
name: scaleway-list-instances
description: "List instances in a zone."
risk: read
inputs_schema:
properties:
zone: { type: string, description: "Zone (defaults to the configured zone)" }
required: []
outputs_schema: { properties: {} }
- id: get_instance
name: scaleway-get-instance
description: "Get an instance by ID."
risk: read
inputs_schema:
properties:
zone: { type: string, description: "Zone (defaults to the configured zone)" }
server_id: { type: string, description: "Instance/server ID" }
required: [server_id]
outputs_schema: { properties: {} }
- id: list_security_groups
name: scaleway-list-security-groups
description: "List security groups in a zone."
risk: read
inputs_schema:
properties:
zone: { type: string, description: "Zone (defaults to the configured zone)" }
required: []
outputs_schema: { properties: {} }
- id: list_projects
name: scaleway-list-projects
description: "List projects in the organization."
risk: read
inputs_schema:
properties: {}
required: []
outputs_schema: { properties: {} }
- id: test_connection
name: scaleway-test-connection
description: "Verify the secret key (used by the Test button)."
risk: read
inputs_schema:
properties: {}
required: []
outputs_schema: { properties: {} }
@@ -0,0 +1,53 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.scaleway.com"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _zone(cfg, inputs):
return (inputs.get("zone") if inputs else None) or cfg.get("default_zone") or "fr-par-1"
def request(method, path, cfg, params=None):
url = BASE + path
if params:
clean = {k: v for k, v in params.items() if v not in (None, "")}
if clean:
url += "?" + urllib.parse.urlencode(clean)
headers = {"X-Auth-Token": str(cfg.get("secret_key", "")), "Accept": "application/json"}
req = urllib.request.Request(url, 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:
print(json.dumps(fn(_cfg(), _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, inputs):
server_id = inputs.get("server_id")
if not server_id:
raise Exception("server_id is required")
zone = _zone(cfg, inputs)
return request("GET", "/instance/v1/zones/" + q(zone) + "/servers/" + q(server_id), cfg)
_run(main)
@@ -0,0 +1,50 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.scaleway.com"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _zone(cfg, inputs):
return (inputs.get("zone") if inputs else None) or cfg.get("default_zone") or "fr-par-1"
def request(method, path, cfg, params=None):
url = BASE + path
if params:
clean = {k: v for k, v in params.items() if v not in (None, "")}
if clean:
url += "?" + urllib.parse.urlencode(clean)
headers = {"X-Auth-Token": str(cfg.get("secret_key", "")), "Accept": "application/json"}
req = urllib.request.Request(url, 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:
print(json.dumps(fn(_cfg(), _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, inputs):
zone = _zone(cfg, inputs)
return request("GET", "/instance/v1/zones/" + q(zone) + "/servers", cfg)
_run(main)
@@ -0,0 +1,49 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.scaleway.com"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _zone(cfg, inputs):
return (inputs.get("zone") if inputs else None) or cfg.get("default_zone") or "fr-par-1"
def request(method, path, cfg, params=None):
url = BASE + path
if params:
clean = {k: v for k, v in params.items() if v not in (None, "")}
if clean:
url += "?" + urllib.parse.urlencode(clean)
headers = {"X-Auth-Token": str(cfg.get("secret_key", "")), "Accept": "application/json"}
req = urllib.request.Request(url, 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:
print(json.dumps(fn(_cfg(), _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, inputs):
return request("GET", "/account/v3/projects", cfg)
_run(main)
@@ -0,0 +1,50 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.scaleway.com"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _zone(cfg, inputs):
return (inputs.get("zone") if inputs else None) or cfg.get("default_zone") or "fr-par-1"
def request(method, path, cfg, params=None):
url = BASE + path
if params:
clean = {k: v for k, v in params.items() if v not in (None, "")}
if clean:
url += "?" + urllib.parse.urlencode(clean)
headers = {"X-Auth-Token": str(cfg.get("secret_key", "")), "Accept": "application/json"}
req = urllib.request.Request(url, 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:
print(json.dumps(fn(_cfg(), _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, inputs):
zone = _zone(cfg, inputs)
return request("GET", "/instance/v1/zones/" + q(zone) + "/security_groups", cfg)
_run(main)
@@ -0,0 +1,50 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.scaleway.com"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _zone(cfg, inputs):
return (inputs.get("zone") if inputs else None) or cfg.get("default_zone") or "fr-par-1"
def request(method, path, cfg, params=None):
url = BASE + path
if params:
clean = {k: v for k, v in params.items() if v not in (None, "")}
if clean:
url += "?" + urllib.parse.urlencode(clean)
headers = {"X-Auth-Token": str(cfg.get("secret_key", "")), "Accept": "application/json"}
req = urllib.request.Request(url, 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:
print(json.dumps(fn(_cfg(), _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, inputs):
request("GET", "/account/v3/projects", cfg)
return {"ok": True}
_run(main)