{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:open-utility-stack:flex-register:1",
  "title": "flex-register@1",
  "description": "A grid operator's registers of flexibility service providers and controllable units, as one data file it serves read-only (fms). It starts the shapes the EU network code on demand response will require; a national register replaces the file later, and the shapes stay. Units sit in homes, so the file is personal data (GDPR): it is served only to the providers and the operator, never published.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "profile",
    "operator",
    "as_of",
    "providers",
    "units"
  ],
  "properties": {
    "profile": {
      "const": "flex-register@1"
    },
    "operator": {
      "description": "The grid operator's market partner id.",
      "type": "string",
      "pattern": "^[0-9]{13}$"
    },
    "as_of": {
      "$ref": "urn:open-utility-stack:common:time:1#/$defs/Date"
    },
    "providers": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "uftp_domain",
          "products"
        ],
        "properties": {
          "id": {
            "description": "The provider's market partner id (13 digits) or EIC.",
            "type": "string",
            "pattern": "^[0-9]{13}$|^[0-9]{2}X[0-9A-Z-]{12}[0-9A-Z]$"
          },
          "name": {
            "description": "The company name; a provider is a business, never a private person in this register.",
            "type": "string",
            "pattern": "\\S",
            "maxLength": 120
          },
          "uftp_domain": {
            "description": "The domain its UFTP messages come from; the sender in flex-offer@1.",
            "type": "string",
            "pattern": "^[a-z0-9.-]+\\.[a-z]{2,}$",
            "maxLength": 253
          },
          "products": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "product",
                "valid_from"
              ],
              "properties": {
                "product": {
                  "description": "What the unit or provider is prequalified for: `uftp-flex` (local flexibility, UFTP), `redispatch-2.0`, `afrr`, `mfrr`, `fcr`, `13k` (Nutzen statt Abregeln), `14a` (controllable consumer).",
                  "type": "string",
                  "pattern": "^[a-z0-9][a-z0-9.-]*$",
                  "maxLength": 32
                },
                "valid_from": {
                  "$ref": "urn:open-utility-stack:common:time:1#/$defs/Date"
                },
                "valid_until": {
                  "$ref": "urn:open-utility-stack:common:time:1#/$defs/Date"
                },
                "by": {
                  "description": "Who prequalified it: the grid or transmission operator's market partner id.",
                  "type": "string",
                  "pattern": "^[0-9]{13}$|^[0-9]{2}X[0-9A-Z-]{12}[0-9A-Z]$"
                }
              }
            }
          },
          "registered_on": {
            "$ref": "urn:open-utility-stack:common:time:1#/$defs/Date"
          }
        }
      }
    },
    "units": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "provider",
          "connection",
          "technology",
          "max_consumption",
          "max_feed_in",
          "products"
        ],
        "properties": {
          "id": {
            "description": "The controllable unit's id in this register.",
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$",
            "maxLength": 64
          },
          "provider": {
            "description": "The service provider's `id`; it must be listed in the same register.",
            "type": "string",
            "pattern": "\\S",
            "maxLength": 32
          },
          "connection": {
            "description": "Where the unit is connected: its Marktlokation, and for Redispatch its technical resource, and the congestion point flex-request@1 names.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "malo"
            ],
            "properties": {
              "malo": {
                "description": "The 11-digit Marktlokation id.",
                "type": "string",
                "pattern": "^[0-9]{11}$"
              },
              "tr_id": {
                "description": "The Redispatch 2.0 technical resource id.",
                "type": "string",
                "pattern": "^[A-Z][0-9A-Z]{10}$"
              },
              "congestion_point": {
                "$ref": "urn:open-utility-stack:common:flex:1#/$defs/EntityAddress"
              }
            }
          },
          "technology": {
            "enum": [
              "battery",
              "heat-pump",
              "ev-charging",
              "pv",
              "chp",
              "industrial-load",
              "other"
            ]
          },
          "max_consumption": {
            "description": "The largest consumption the unit can be moved to, in watts, at least 0.",
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740992
          },
          "max_feed_in": {
            "description": "The largest feed-in, as a positive magnitude in watts; 0 for a pure load.",
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740992
          },
          "baseline": {
            "description": "The baseline method the unit is settled by.",
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]*@[1-9][0-9]*$"
          },
          "products": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "product",
                "valid_from"
              ],
              "properties": {
                "product": {
                  "description": "What the unit or provider is prequalified for: `uftp-flex` (local flexibility, UFTP), `redispatch-2.0`, `afrr`, `mfrr`, `fcr`, `13k` (Nutzen statt Abregeln), `14a` (controllable consumer).",
                  "type": "string",
                  "pattern": "^[a-z0-9][a-z0-9.-]*$",
                  "maxLength": 32
                },
                "valid_from": {
                  "$ref": "urn:open-utility-stack:common:time:1#/$defs/Date"
                },
                "valid_until": {
                  "$ref": "urn:open-utility-stack:common:time:1#/$defs/Date"
                },
                "by": {
                  "description": "Who prequalified it: the grid or transmission operator's market partner id.",
                  "type": "string",
                  "pattern": "^[0-9]{13}$|^[0-9]{2}X[0-9A-Z-]{12}[0-9A-Z]$"
                }
              }
            }
          }
        }
      }
    },
    "extensions": {
      "type": "object",
      "propertyNames": {
        "pattern": "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)*$"
      },
      "additionalProperties": {
        "type": "object"
      }
    }
  }
}
