Controller REST APIの障害対応4 / 6

調査用のrequest

response = session.get(url, timeout=(5,20))
response.raise_for_status()
if "application/json" not in response.headers.get("Content-Type", "").lower():
    raise RuntimeError("Expected API JSON response")
data = response.json()
if not isinstance(data, dict):
    raise RuntimeError("Unexpected response structure")

これはJSON objectを返す監視endpoint用の形である。YANG JSON等の別media type、JSON arrayを返す契約では、その契約へ検証を合わせる。全APIへ一つの固定wrapperを強制しない。error情報にはsecretを含まない必要なtag/code/対象だけを記録する。

学習パスへ
参考資料