{
  "title": "hub.integration.1",
  "description": "Defines a version 1 integration message payload",
  "type": "object",
  "required": [ "message", "integration" ],
  "properties": {
    "message": {
      "type": "object",
      "required": [ "id", "applicationId", "dateTime" ],
      "properties": {
        "version": {
          "type": "integer",
          "exclusiveMinimum": 0
        },
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "relatedId": {
          "type": "string",
          "format": "uuid"
        },
        "applicationId": {
          "type": "string"
        },
        "dateTime": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "integration": {
      "type": "object",
      "required": [ "type" ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [ "registration", "deregistration" ]
        },
        "response": {
          "type": "object",
          "required": [ "iamModuleApplicationId", "boundary", "apiBaseUrl", "clusterInternalApiBaseUrl", "iamModuleSuperAdminRoleId", "keycloakBaseUrl", "clusterInternalKeycloakBaseUrl", "keycloakRealm" ],
          "properties": {
            "iamModuleApplicationId": {
              "type": "string"
            },
            "boundary": {
              "type": "string"
            },
            "apiBaseUrl": {
              "type": "string"
            },
            "clusterInternalApiBaseUrl": {
              "type": "string"
            },
            "iamModuleSuperAdminRoleId": {
              "type": "string"
            },
            "keycloakBaseUrl": {
              "type": "string"
            },
            "clusterInternalKeycloakBaseUrl": {
              "type": "string"
            },
            "keycloakRealm": {
              "type": "string"
            },
            "clientId": {
              "type": "string"
            }
          }
        },
        "endpoints": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [ "purpose", "uri" ],
            "properties": {
              "purpose": {
                "type": "string"
              },
              "uri": { "type": "string" },
              "boundary": { "type": "string" },
              "permissions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [ "roles" ],
                  "properties": {
                    "roles": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "array",
                        "items": { "type": "string" }
                      }
                    },
                    "context": {
                      "type": "object",
                      "properties": {
                        "entities": {
                          "type": "array",
                          "items": { "type": "string" }
                        },
                        "entityGroups": {
                          "type": "array",
                          "items": { "type": "string" }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "config": {
          "type": "object",
          "properties": {
            "values": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [ "key", "value" ],
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "value": {
                    "oneOf": [
                      { "type": "string" },
                      { "type": "object" }
                    ]
                  }
                }
              }
            },
            "external": {
              "type": "string"
            }
          }
        },
        "client": {
          "type": "object",
          "properties": {
            "clientId": {
              "type": "string"
            },
            "rootUrl": {
              "type": "string"
            },
            "baseUrl": {
              "type": "string"
            },
            "adminUrl": {
              "type": "string"
            },
            "redirectUris": {
              "type": "array",
              "items": { "type": "string" }
            },
            "webOrigins": {
              "type": "array",
              "items": { "type": "string" }
            },
            "boundaries": {
              "type": "array",
              "items": { "type": "string" }
            },
            "permissions": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [ "roles" ],
                "properties": {
                  "roles": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "array",
                      "items": { "type": "string" }
                    }
                  },
                  "context": {
                    "type": "object",
                    "properties": {
                      "entities": {
                        "type": "array",
                        "items": { "type": "string" }
                      },
                      "entityGroups": {
                        "type": "array",
                        "items": { "type": "string" }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}