{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "schemaVersion": {
      "const": "1.0.0"
    },
    "graphId": {
      "type": "string",
      "minLength": 1
    },
    "metadata": {
      "type": "object",
      "properties": {
        "catalogVersion": {
          "type": "string",
          "minLength": 1
        },
        "catalogPublishedAt": {
          "type": "string",
          "format": "date-time"
        },
        "catalogVerifiedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "collectedAt": {
          "type": "string",
          "format": "date-time"
        },
        "collectionStartedAt": {
          "type": "string",
          "format": "date-time"
        },
        "collectionFinishedAt": {
          "type": "string",
          "format": "date-time"
        },
        "inputKind": {
          "enum": [
            "api",
            "usacloud",
            "terraform-state",
            "terraform-plan",
            "terraform-hcl",
            "yaml",
            "mixed"
          ]
        },
        "completeness": {
          "enum": [
            "complete",
            "partial",
            "proposal"
          ]
        },
        "coverage": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "scope": {
                "type": "string",
                "minLength": 1
              },
              "status": {
                "enum": [
                  "ok",
                  "forbidden",
                  "unsupported",
                  "failed",
                  "not-requested"
                ]
              },
              "count": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "scope",
              "status",
              "count"
            ],
            "additionalProperties": false
          }
        },
        "redactionProfile": {
          "type": "string",
          "minLength": 1
        },
        "catalogFreshness": {
          "type": "object",
          "properties": {
            "evaluatedAt": {
              "type": "string",
              "format": "date-time"
            },
            "status": {
              "enum": [
                "fresh",
                "stale",
                "source-failed",
                "unverified"
              ]
            },
            "thresholdDays": {
              "type": "integer",
              "minimum": 1
            },
            "oldestRequiredVerification": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "failedSourceCount": {
              "type": "integer",
              "minimum": 0
            },
            "manifestDigest": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "evaluatedAt",
            "status",
            "thresholdDays",
            "oldestRequiredVerification",
            "failedSourceCount",
            "manifestDigest"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "catalogVersion",
        "catalogPublishedAt",
        "catalogVerifiedAt",
        "collectedAt",
        "collectionStartedAt",
        "collectionFinishedAt",
        "inputKind",
        "completeness",
        "coverage",
        "redactionProfile",
        "catalogFreshness"
      ],
      "additionalProperties": false
    },
    "nodes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/node"
      }
    },
    "edges": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/edge"
      }
    },
    "groups": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/group"
      }
    },
    "diagnostics": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "minLength": 1
          },
          "severity": {
            "enum": [
              "info",
              "warning",
              "error"
            ]
          },
          "message": {
            "type": "string"
          },
          "resourceIds": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        "required": [
          "code",
          "severity",
          "message",
          "resourceIds"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "schemaVersion",
    "graphId",
    "metadata",
    "nodes",
    "edges",
    "groups",
    "diagnostics"
  ],
  "additionalProperties": false,
  "$defs": {
    "node": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "minLength": 1
        },
        "label": {
          "type": "string"
        },
        "scope": {
          "type": "object",
          "properties": {
            "project": {
              "type": "string",
              "minLength": 1
            },
            "service": {
              "type": "string",
              "minLength": 1
            },
            "zone": {
              "type": [
                "string",
                "null"
              ]
            },
            "region": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "project",
            "service",
            "zone",
            "region"
          ],
          "additionalProperties": false
        },
        "nativeId": {
          "type": [
            "string",
            "null"
          ]
        },
        "lifecycle": {
          "enum": [
            "observed",
            "planned",
            "proposed",
            "deleting",
            "unknown"
          ]
        },
        "attributes": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/attribute"
          }
        },
        "provenance": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/provenance"
          }
        },
        "extensions": {
          "type": "object"
        }
      },
      "required": [
        "id",
        "type",
        "label",
        "scope",
        "lifecycle",
        "attributes",
        "provenance"
      ],
      "additionalProperties": false
    },
    "edge": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "type": "string",
          "minLength": 1
        },
        "target": {
          "type": "string",
          "minLength": 1
        },
        "relation": {
          "type": "string",
          "minLength": 1
        },
        "sourcePort": {
          "type": [
            "string",
            "null"
          ]
        },
        "targetPort": {
          "type": [
            "string",
            "null"
          ]
        },
        "evidence": {
          "enum": [
            "explicit",
            "inferred",
            "unresolved"
          ]
        },
        "plane": {
          "enum": [
            "network",
            "storage",
            "dependency",
            "logical"
          ]
        },
        "provenance": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/provenance"
          }
        },
        "extensions": {
          "type": "object"
        }
      },
      "required": [
        "id",
        "source",
        "target",
        "relation",
        "evidence",
        "plane",
        "provenance"
      ],
      "additionalProperties": false
    },
    "group": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "kind": {
          "type": "string",
          "minLength": 1
        },
        "label": {
          "type": "string"
        },
        "parentId": {
          "type": [
            "string",
            "null"
          ]
        },
        "members": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "boundary": {
          "enum": [
            "physical",
            "logical",
            "presentation"
          ]
        },
        "provenance": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/provenance"
          }
        }
      },
      "required": [
        "id",
        "kind",
        "label",
        "parentId",
        "members",
        "boundary",
        "provenance"
      ],
      "additionalProperties": false
    },
    "provenance": {
      "type": "object",
      "properties": {
        "sourceId": {
          "type": "string",
          "minLength": 1
        },
        "sourceUrl": {
          "type": "string",
          "format": "uri"
        },
        "retrievedAt": {
          "type": "string",
          "format": "date-time"
        },
        "schemaVersion": {
          "type": "string",
          "minLength": 1
        },
        "locator": {
          "type": "string"
        }
      },
      "required": [
        "sourceId",
        "sourceUrl",
        "retrievedAt",
        "schemaVersion",
        "locator"
      ],
      "additionalProperties": false
    },
    "attribute": {
      "type": "object",
      "properties": {
        "value": {},
        "state": {
          "enum": [
            "known",
            "unknown",
            "redacted"
          ]
        },
        "classification": {
          "enum": [
            "public",
            "internal",
            "confidential",
            "secret"
          ]
        },
        "unit": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "value",
        "state",
        "classification"
      ],
      "additionalProperties": false
    }
  }
}