{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://owlie.com/docs/schemas/connectors/definitions/ldap.schema.json",
  "title": "Owlie LDAP connector definition",
  "description": "The definition.json of a ldap connector (engine major 1). Owlie derives the connector's manifest from it. A value the definition makes install-editable is a bare { \"$oxl\": \"config.<name>\" } naming a field declared under config.properties; each install keeps its own copy, seeded from the field's default.",
  "type": "object",
  "required": ["engine", "entities"],
  "additionalProperties": false,
  "properties": {
    "engine": {
      "type": "integer",
      "const": 1
    },
    "description": {
      "type": "string",
      "minLength": 1
    },
    "icon": {
      "type": "string",
      "minLength": 1
    },
    "config": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "properties": {
          "type": "object",
          "additionalProperties": {
            "type": "object"
          }
        }
      }
    },
    "pageSize": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000,
          "default": 500
        },
        {
          "type": "object",
          "required": ["$oxl"],
          "additionalProperties": false,
          "properties": {
            "$oxl": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      ]
    },
    "entities": {
      "type": "object",
      "required": ["user"],
      "properties": {
        "user": {
          "type": "object",
          "required": ["identifier", "rdnAttribute"],
          "additionalProperties": false,
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1
            },
            "bases": {
              "anyOf": [
                {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                {
                  "type": "object",
                  "required": ["$oxl"],
                  "additionalProperties": false,
                  "properties": {
                    "$oxl": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                }
              ]
            },
            "scope": {
              "enum": ["base", "one", "sub"],
              "default": "sub"
            },
            "objectClasses": {
              "anyOf": [
                {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                {
                  "type": "object",
                  "required": ["$oxl"],
                  "additionalProperties": false,
                  "properties": {
                    "$oxl": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                }
              ]
            },
            "filter": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1
                },
                {
                  "type": "object",
                  "required": ["$oxl"],
                  "additionalProperties": false,
                  "properties": {
                    "$oxl": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                }
              ]
            },
            "identifier": {
              "type": "object",
              "required": ["attribute"],
              "additionalProperties": false,
              "properties": {
                "attribute": {
                  "type": "string",
                  "minLength": 1
                },
                "type": {
                  "enum": ["string", "binary", "guid"],
                  "default": "string"
                }
              }
            },
            "rdnAttribute": {
              "type": "string",
              "minLength": 1
            },
            "attributes": {
              "anyOf": [
                {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "enum": ["string", "number", "boolean", "binary", "guid", "sid"],
                        "default": "string"
                      },
                      "multi": {
                        "type": "boolean",
                        "default": false
                      },
                      "title": {
                        "type": "string"
                      },
                      "sensitive": {
                        "type": "boolean",
                        "default": false
                      },
                      "readOnly": {
                        "type": "boolean",
                        "default": false
                      },
                      "baseline": {
                        "title": "Provisioning baseline",
                        "anyOf": [
                          {
                            "type": "string",
                            "minLength": 1,
                            "description": "An OXL expression over the identity"
                          },
                          {
                            "type": "object",
                            "required": ["usernameGenerator"],
                            "additionalProperties": false,
                            "properties": {
                              "usernameGenerator": {
                                "type": "object",
                                "required": ["steps", "maxAttempts"],
                                "description": "A username generator: ordered steps of blocks, and maxAttempts"
                              }
                            }
                          }
                        ]
                      }
                    }
                  }
                },
                {
                  "type": "object",
                  "required": ["$oxl"],
                  "additionalProperties": false,
                  "properties": {
                    "$oxl": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                }
              ]
            },
            "write": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "base": {
                  "anyOf": [
                    {
                      "type": "string",
                      "minLength": 1
                    },
                    {
                      "type": "object",
                      "required": ["$oxl"],
                      "additionalProperties": false,
                      "properties": {
                        "$oxl": {
                          "type": "string",
                          "minLength": 1
                        }
                      }
                    }
                  ]
                },
                "dn": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "object",
                      "required": ["$oxl"],
                      "additionalProperties": false,
                      "properties": {
                        "$oxl": {
                          "type": "string",
                          "minLength": 1
                        }
                      }
                    }
                  ]
                },
                "delete": {
                  "type": "boolean",
                  "default": false
                }
              }
            },
            "lifecycle": {
              "anyOf": [
                {
                  "type": "object",
                  "required": ["attribute", "disabledValue"],
                  "additionalProperties": false,
                  "properties": {
                    "attribute": {
                      "anyOf": [
                        {
                          "type": "string",
                          "minLength": 1
                        },
                        {
                          "type": "object",
                          "required": ["$oxl"],
                          "additionalProperties": false,
                          "properties": {
                            "$oxl": {
                              "type": "string",
                              "minLength": 1
                            }
                          }
                        }
                      ]
                    },
                    "enabledValue": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "required": ["$oxl"],
                          "additionalProperties": false,
                          "properties": {
                            "$oxl": {
                              "type": "string",
                              "minLength": 1
                            }
                          }
                        }
                      ]
                    },
                    "disabledValue": {
                      "anyOf": [
                        {
                          "type": "string",
                          "minLength": 1
                        },
                        {
                          "type": "object",
                          "required": ["$oxl"],
                          "additionalProperties": false,
                          "properties": {
                            "$oxl": {
                              "type": "string",
                              "minLength": 1
                            }
                          }
                        }
                      ]
                    }
                  }
                },
                {
                  "type": "object",
                  "required": ["attribute", "disabledFlag", "newAccountValue"],
                  "additionalProperties": false,
                  "properties": {
                    "attribute": {
                      "type": "string",
                      "minLength": 1
                    },
                    "disabledFlag": {
                      "type": "integer",
                      "minimum": 1
                    },
                    "newAccountValue": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              ]
            },
            "password": {
              "type": "object",
              "required": ["attribute"],
              "additionalProperties": false,
              "properties": {
                "attribute": {
                  "type": "string",
                  "minLength": 1
                },
                "encoding": {
                  "enum": ["text", "unicodePwd"],
                  "default": "text"
                },
                "on_change": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                }
              }
            },
            "matching": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "employeeId": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "object",
                      "required": ["$oxl"],
                      "additionalProperties": false,
                      "properties": {
                        "$oxl": {
                          "type": "string",
                          "minLength": 1
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        },
        "group": {
          "type": "object",
          "required": ["identifier", "rdnAttribute", "membership"],
          "additionalProperties": false,
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1
            },
            "bases": {
              "anyOf": [
                {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                {
                  "type": "object",
                  "required": ["$oxl"],
                  "additionalProperties": false,
                  "properties": {
                    "$oxl": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                }
              ]
            },
            "scope": {
              "enum": ["base", "one", "sub"],
              "default": "sub"
            },
            "objectClasses": {
              "anyOf": [
                {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                {
                  "type": "object",
                  "required": ["$oxl"],
                  "additionalProperties": false,
                  "properties": {
                    "$oxl": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                }
              ]
            },
            "filter": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1
                },
                {
                  "type": "object",
                  "required": ["$oxl"],
                  "additionalProperties": false,
                  "properties": {
                    "$oxl": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                }
              ]
            },
            "identifier": {
              "type": "object",
              "required": ["attribute"],
              "additionalProperties": false,
              "properties": {
                "attribute": {
                  "type": "string",
                  "minLength": 1
                },
                "type": {
                  "enum": ["string", "binary", "guid"],
                  "default": "string"
                }
              }
            },
            "rdnAttribute": {
              "type": "string",
              "minLength": 1
            },
            "attributes": {
              "anyOf": [
                {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "enum": ["string", "number", "boolean", "binary", "guid", "sid"],
                        "default": "string"
                      },
                      "multi": {
                        "type": "boolean",
                        "default": false
                      },
                      "title": {
                        "type": "string"
                      },
                      "sensitive": {
                        "type": "boolean",
                        "default": false
                      },
                      "readOnly": {
                        "type": "boolean",
                        "default": false
                      },
                      "baseline": {
                        "title": "Provisioning baseline",
                        "anyOf": [
                          {
                            "type": "string",
                            "minLength": 1,
                            "description": "An OXL expression over the identity"
                          },
                          {
                            "type": "object",
                            "required": ["usernameGenerator"],
                            "additionalProperties": false,
                            "properties": {
                              "usernameGenerator": {
                                "type": "object",
                                "required": ["steps", "maxAttempts"],
                                "description": "A username generator: ordered steps of blocks, and maxAttempts"
                              }
                            }
                          }
                        ]
                      }
                    }
                  }
                },
                {
                  "type": "object",
                  "required": ["$oxl"],
                  "additionalProperties": false,
                  "properties": {
                    "$oxl": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                }
              ]
            },
            "write": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "base": {
                  "anyOf": [
                    {
                      "type": "string",
                      "minLength": 1
                    },
                    {
                      "type": "object",
                      "required": ["$oxl"],
                      "additionalProperties": false,
                      "properties": {
                        "$oxl": {
                          "type": "string",
                          "minLength": 1
                        }
                      }
                    }
                  ]
                },
                "dn": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "object",
                      "required": ["$oxl"],
                      "additionalProperties": false,
                      "properties": {
                        "$oxl": {
                          "type": "string",
                          "minLength": 1
                        }
                      }
                    }
                  ]
                },
                "delete": {
                  "type": "boolean",
                  "default": false
                }
              }
            },
            "membership": {
              "type": "object",
              "required": ["attribute"],
              "additionalProperties": false,
              "properties": {
                "attribute": {
                  "type": "string",
                  "minLength": 1
                },
                "direction": {
                  "enum": ["member-on-group", "memberOf-on-account"],
                  "default": "member-on-group"
                },
                "writable": {
                  "type": "boolean",
                  "default": false
                },
                "nested": {
                  "anyOf": [
                    {
                      "type": "boolean",
                      "default": false
                    },
                    {
                      "type": "object",
                      "required": ["$oxl"],
                      "additionalProperties": false,
                      "properties": {
                        "$oxl": {
                          "type": "string",
                          "minLength": 1
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "additionalProperties": {
        "type": "object",
        "required": ["identifier", "rdnAttribute"],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "bases": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              },
              {
                "type": "object",
                "required": ["$oxl"],
                "additionalProperties": false,
                "properties": {
                  "$oxl": {
                    "type": "string",
                    "minLength": 1
                  }
                }
              }
            ]
          },
          "scope": {
            "enum": ["base", "one", "sub"],
            "default": "sub"
          },
          "objectClasses": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              },
              {
                "type": "object",
                "required": ["$oxl"],
                "additionalProperties": false,
                "properties": {
                  "$oxl": {
                    "type": "string",
                    "minLength": 1
                  }
                }
              }
            ]
          },
          "filter": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "object",
                "required": ["$oxl"],
                "additionalProperties": false,
                "properties": {
                  "$oxl": {
                    "type": "string",
                    "minLength": 1
                  }
                }
              }
            ]
          },
          "identifier": {
            "type": "object",
            "required": ["attribute"],
            "additionalProperties": false,
            "properties": {
              "attribute": {
                "type": "string",
                "minLength": 1
              },
              "type": {
                "enum": ["string", "binary", "guid"],
                "default": "string"
              }
            }
          },
          "rdnAttribute": {
            "type": "string",
            "minLength": 1
          },
          "attributes": {
            "anyOf": [
              {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "type": {
                      "enum": ["string", "number", "boolean", "binary", "guid", "sid"],
                      "default": "string"
                    },
                    "multi": {
                      "type": "boolean",
                      "default": false
                    },
                    "title": {
                      "type": "string"
                    },
                    "sensitive": {
                      "type": "boolean",
                      "default": false
                    },
                    "readOnly": {
                      "type": "boolean",
                      "default": false
                    },
                    "baseline": {
                      "title": "Provisioning baseline",
                      "anyOf": [
                        {
                          "type": "string",
                          "minLength": 1,
                          "description": "An OXL expression over the identity"
                        },
                        {
                          "type": "object",
                          "required": ["usernameGenerator"],
                          "additionalProperties": false,
                          "properties": {
                            "usernameGenerator": {
                              "type": "object",
                              "required": ["steps", "maxAttempts"],
                              "description": "A username generator: ordered steps of blocks, and maxAttempts"
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              },
              {
                "type": "object",
                "required": ["$oxl"],
                "additionalProperties": false,
                "properties": {
                  "$oxl": {
                    "type": "string",
                    "minLength": 1
                  }
                }
              }
            ]
          }
        }
      }
    },
    "incremental": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "attribute": {
          "type": "string",
          "minLength": 1,
          "default": "modifyTimestamp"
        },
        "kind": {
          "enum": ["timestamp", "counter"],
          "default": "timestamp"
        },
        "overlapSeconds": {
          "type": "integer",
          "minimum": 0,
          "maximum": 86400,
          "default": 300
        },
        "source": {
          "enum": ["invocationId"]
        }
      }
    },
    "handlers": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "required": ["script"],
        "additionalProperties": false,
        "properties": {
          "script": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"
          },
          "timeoutMs": {
            "type": "integer",
            "minimum": 1,
            "maximum": 900000
          },
          "secrets": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "minLength": 1
            }
          },
          "config": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      }
    },
    "custom_ops": {
      "type": "object",
      "additionalProperties": {
        "anyOf": [
          {
            "type": "object",
            "required": ["script"],
            "additionalProperties": false,
            "properties": {
              "script": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"
              },
              "timeoutMs": {
                "type": "integer",
                "minimum": 1,
                "maximum": 900000
              },
              "secrets": {
                "type": "object",
                "additionalProperties": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "config": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "entity": {
                "type": "string",
                "minLength": 1
              },
              "title": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "params_schema": {
                "type": "object"
              }
            }
          },
          {
            "type": "object",
            "required": ["ldap"],
            "additionalProperties": false,
            "properties": {
              "ldap": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "replace": {
                    "type": "object",
                    "additionalProperties": {
                      "type": ["string", "null"]
                    }
                  },
                  "move": {
                    "type": "object",
                    "required": ["param"],
                    "additionalProperties": false,
                    "properties": {
                      "param": {
                        "type": "string",
                        "minLength": 1
                      }
                    }
                  }
                }
              },
              "entity": {
                "enum": ["user", "group"]
              },
              "title": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "params_schema": {
                "type": "object"
              }
            }
          }
        ]
      }
    }
  }
}
