{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.mpai.community/AIF/V2.0/AIW-AIM-metadata.schema.json",
  "title": "AIW/AIM metadata for MPAI-AIF V2",
  "type": "object",
  "properties": {
    "Identifier": {
      "description": "Information uniquely identifying an AIW/AIM implementation",
      "type": "object",
      "$anchor": "identifier",
      "properties": {
        "ImplementerID": {
          "description": "String assigned by IIDRA",
          "type": "string"
        },
        "Specification": {
          "oneOf": [
            {
              "description": "An AIW/AIM defined by an MPAI standard",
              "type": "object",
              "properties": {
                "Standard": {
                  "description": "Defined by the Standard",
                  "type": "string"
                },
                "AIW": {
                  "description": "Defined by the Standard",
                  "type": "string"
                },
                "AIM": {
                  "description": "Same as AIW when the Metadata being defined describes the AIW; otherwise, the name of the AIM as defined by the Standard",
                  "type": "string"
                },
                "Version": {
                  "description": "Defined by the Standard",
                  "type": "string"
                },
                "Profile": {
                  "description": "Provided by MPAI. Selected by the Implementer",
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "Base",
                      "Main",
                      "High"
                    ]
                  }
                }
              },
              "required": [
                "Standard",
                "AIW",
                "AIM",
                "Version"
              ]
            },
            {
              "description": "An AIW/AIM defined by an Implementer",
              "type": "object",
              "properties": {
                "Name": {
                  "description": "Provided by the Implementer",
                  "type": "string"
                },
                "Version": {
                  "description": "Provided by the Implementer",
                  "type": "string"
                }
              },
              "required": [
                "Name",
                "Version"
              ]
            }
          ]
        }
      },
      "required": [
        "ImplementerID",
        "Specification"
      ]
    },
    "APIProfile": {
      "description": "Provided by MPAI. Selected by the Implementer",
      "type": "string",
      "enum": [
        "Basic",
        "Secure"
      ]
    },
    "Description": {
      "description": "Free text describing the AIM",
      "type": "string"
    },
    "Types": {
      "description": "A list of shorthands for Channel data types, defined according to 6.1.1",
      "type": "array",
      "items": {
        "description": "A shorthand for a Channel data type, defined according to 6.1.1",
        "type": "object",
        "properties": {
          "Name": {
            "description": "The unique shorthand used for a Channel data type",
            "type": "string"
          },
          "Type": {
            "description": "A Channel data type, defined according to 6.1.1",
            "type": "string"
          }
        },
        "required": [
          "Name",
          "Type"
        ]
      }
    },
    "Ports": {
      "description": "A list of AIM Ports",
      "type": "array",
      "items": {
        "description": "A Port, i.e., a physical or logical interface through which the AIM communicates",
        "type": "object",
        "properties": {
          "Name": {
            "description": "Implementer-defined name",
            "type": "string"
          },
          "Direction": {
            "description": "The direction of the communication flow",
            "type": "string",
            "enum": [
              "OutputInput",
              "InputOutput"
            ]
          },
          "RecordType": {
            "description": "Port data type defined either in the dictionary Types, or according to Section 6.1.1",
            "type": "string"
          },
          "Technology": {
            "description": "Whether the Port is implemented in hardware or software",
            "type": "string",
            "enum": [
              "Hardware",
              "Software"
            ]
          },
          "Protocol": {
            "description": "An entry in the MPAI-specified Ontology",
            "type": "string"
          },
          "IsRemote": {
            "description": "Boolean specifying whether the port is remote",
            "type": "boolean"
          }
        },
        "required": [
          "Name",
          "Direction",
          "RecordType",
          "Technology",
          "Protocol",
          "IsRemote"
        ]
      }
    },
    "SubAIMs": {
      "description": "A list of AIMs in terms of which the current AIM is defined",
      "type": "array",
      "items": {
        "description": "One of the AIMs in terms of which the current AIM is defined",
        "type": "object",
        "properties": {
          "Name": {
            "description": "A unique shorthand for the AIM in terms of which the current AIM is defined",
            "type": "string"
          },
          "Identifier": {
            "$ref": "#identifier"
          }
        },
        "required": [
          "Name",
          "Identifier"
        ]
      }
    },
    "Topology": {
      "description": "A list of Channels connecting one Output to one Input Port",
      "type": "array",
      "items": {
        "description": "A Channel connecting one Output to one Input Port",
        "type": "object",
        "properties": {
          "Output": {
            "description": "A Port identifier",
            "type": "object",
            "$anchor": "portID",
            "properties": {
              "AIMName": {
                "description": "The unique shorthand for a SubAIM",
                "type": "string"
              },
              "PortName": {
                "description": "The unique shorthand for one of the SubAIM Ports",
                "type": "string"
              }
            },
            "required": [
              "AIMName",
              "PortName"
            ]
          },
          "Input": {
            "$ref": "#portID"
          }
        },
        "required": [
          "Output",
          "Input"
        ]
      }
    },
    "Implementations": {
      "description": "A list of Implementations for the AIM being defined",
      "type": "array",
      "items": {
        "description": "An Implementation for the AIM being defined",
        "type": "object",
        "properties": {
          "BinaryName": {
            "description": "Specifies an entry in the archive containing the Implementation downloaded from the Store",
            "type": "string"
          },
          "Architecture": {
            "description": "An entry in the MPAI-specified Ontology",
            "type": "string"
          },
          "OperatingSystem": {
            "description": "An entry in the MPAI-specified Ontology",
            "type": "string"
          },
          "Version": {
            "description": "An entry in the MPAI-specified Ontology",
            "type": "string"
          },
          "Source": {
            "description": "Where the AIM Implementation should be found",
            "type": "string",
            "enum": [
              "AIMStorage",
              "MPAIStore"
            ]
          },
          "Destination": {
            "description": "If empty, the Implementation is executed locally. Otherwise, the string shall be a valid URI of an MPAI Server",
            "type": "string"
          }
        },
        "required": [
          "BinaryName",
          "Architecture",
          "OperatingSystem",
          "Version",
          "Source"
        ]
      }
    },
    "ResourcePolicies": {
      "description": "A set of policies describing computing resources needed by the AIW/AIF being defined",
      "type": "array",
      "items": {
        "description": "A policy describing computing resources needed by the AIW/AIF being defined",
        "type": "object",
        "properties": {
          "Name": {
            "description": "An entry in the MPAI-specified Ontology",
            "type": "string"
          },
          "Minimum": {
            "description": "An entry in the MPAI-specified Ontology",
            "type": "string"
          },
          "Maximum": {
            "description": "An entry in the MPAI-specified Ontology",
            "type": "string"
          },
          "Request": {
            "description": "An entry in the MPAI-specified Ontology",
            "type": "string"
          }
        },
        "required": [
          "Name"
        ]
      }
    },
    "Documentation": {
      "description": "A list of references to documents specifying information relevant to the design, implementation and usage of the AIM being defined",
      "type": "array",
      "items": {
        "description": "A reference to a document specifying information relevant to the design, implementation and usage of the AIM being defined",
        "type": "object",
        "properties": {
          "Type": {
            "description": "The type of the document",
            "type": "string",
            "enum": [
              "Specification",
              "Manual",
              "Tutorial",
              "Video"
            ]
          },
          "URI": {
            "description": "A valid URI for the document",
            "type": "string"
          }
        },
        "required": [
          "Type",
          "URI"
        ]
      }
    }
  },
  "required": [
    "Identifier",
    "Ports",
    "SubAIMs",
    "Topology",
    "Implementations"
  ],
  "$id": "https://schemas.mpai.community/AIF/V2.0/AIW-AIM-metadata.schema.json"
}
