{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "additionalProperties": false,
  "description": "HTTP request settings. The body is a separate send argument. Supply a full URL in path here or in the send overrides.",
  "properties": {
    "verb": {
      "anyOf": [
        {
          "enum": [
            "get",
            "post",
            "put",
            "delete",
            "patch",
            "head"
          ]
        },
        {
          "type": "string",
          "pattern": "^\\{\\{.+\\}\\}$"
        }
      ],
      "description": "Lowercase HTTP verb; default post. Only post, put and patch send the supplied body."
    },
    "path": {
      "type": "string",
      "minLength": 1,
      "description": "Full HTTP or HTTPS destination URL, including any query string."
    },
    "headers": {
      "anyOf": [
        {
          "type": "object",
          "additionalProperties": {}
        },
        {
          "type": "string",
          "pattern": "^\\{\\{.+\\}\\}$"
        }
      ],
      "description": "Header names and values. Values are converted to text; declared Secret expressions can supply confidential values."
    },
    "timeout": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 1
        },
        {
          "type": "string",
          "pattern": "^\\{\\{.+\\}\\}$"
        }
      ],
      "description": "Positive request timeout in milliseconds; default 30000."
    },
    "async": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "string",
          "pattern": "^\\{\\{.+\\}\\}$"
        }
      ],
      "description": "Default false. True submits asynchronously and returns null, discarding the response."
    }
  },
  "$defs": {
    "tcpProtocol": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "frame",
        "sections"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "frame": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "length",
            "type"
          ],
          "properties": {
            "length": {
              "type": "integer",
              "minimum": 1
            },
            "type": {
              "enum": [
                "uint",
                "binary",
                "ascii",
                "numeric"
              ]
            },
            "endian": {
              "enum": [
                "big",
                "little"
              ],
              "default": "big",
              "description": "Parser accepts both; current integer framing writes big-endian. See Service.md."
            }
          }
        },
        "sections": {
          "type": "object",
          "minProperties": 1,
          "additionalProperties": {
            "$ref": "#/$defs/tcpSection"
          }
        }
      }
    },
    "tcpBitmap": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "primary": {
          "type": "integer",
          "minimum": 1
        },
        "secondary": {
          "type": "integer",
          "minimum": 0
        },
        "type": {
          "enum": [
            "binary",
            "ascii"
          ],
          "default": "binary"
        },
        "bitOrder": {
          "enum": [
            "msb",
            "lsb"
          ],
          "default": "msb"
        }
      },
      "required": [
        "primary"
      ]
    },
    "tcpSection": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "fields"
      ],
      "properties": {
        "fields": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/tcpField"
          }
        },
        "bitmap": {
          "$ref": "#/$defs/tcpBitmap"
        }
      }
    },
    "tcpFieldLength": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "format"
      ],
      "properties": {
        "format": {
          "enum": [
            "fixed",
            "prefixed",
            "remaining"
          ]
        },
        "value": {
          "type": "integer",
          "minimum": 0
        },
        "min": {
          "type": "integer",
          "minimum": 0
        },
        "max": {
          "type": "integer",
          "minimum": 0
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "format": {
                "enum": [
                  "fixed",
                  "prefixed"
                ]
              }
            },
            "required": [
              "format"
            ]
          },
          "then": {
            "required": [
              "value"
            ]
          }
        }
      ]
    },
    "tcpField": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "length"
      ],
      "properties": {
        "id": {
          "type": "integer",
          "minimum": 0
        },
        "name": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "type": {
          "enum": [
            "ascii",
            "numeric",
            "binary",
            "bcd",
            "uint",
            "msb",
            "lsb"
          ],
          "default": "ascii"
        },
        "endian": {
          "enum": [
            "big",
            "little"
          ],
          "default": "big"
        },
        "length": {
          "$ref": "#/$defs/tcpFieldLength"
        },
        "fields": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/tcpField"
          }
        },
        "bitmap": {
          "$ref": "#/$defs/tcpBitmap"
        },
        "tlv": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/tcpTlv"
          }
        }
      }
    },
    "tcpTlv": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "tag",
        "length",
        "value"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "tag": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "length"
          ],
          "properties": {
            "name": {
              "type": "string"
            },
            "type": {
              "enum": [
                "binary",
                "ascii",
                "numeric",
                "bcd",
                "uint"
              ],
              "default": "binary"
            },
            "endian": {
              "enum": [
                "big",
                "little"
              ],
              "default": "big"
            },
            "length": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "format",
                "value"
              ],
              "properties": {
                "format": {
                  "const": "fixed"
                },
                "value": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          }
        },
        "length": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "enum": [
                "emv",
                "binary",
                "uint",
                "ascii",
                "numeric"
              ]
            },
            "format": {
              "enum": [
                "fixed",
                "prefixed"
              ]
            },
            "value": {
              "type": "integer",
              "minimum": 1
            }
          },
          "allOf": [
            {
              "if": {
                "properties": {
                  "type": {
                    "enum": [
                      "binary",
                      "uint",
                      "ascii",
                      "numeric"
                    ]
                  }
                },
                "required": [
                  "type"
                ]
              },
              "then": {
                "required": [
                  "format",
                  "value"
                ]
              }
            }
          ]
        },
        "value": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "enum": [
                "binary",
                "ascii",
                "numeric",
                "bcd",
                "uint",
                "msb",
                "lsb"
              ]
            }
          }
        }
      }
    },
    "httpRequest": {
      "type": "object",
      "additionalProperties": false,
      "description": "HTTP request settings. The body is a separate send argument. Supply a full URL in path here or in the send overrides.",
      "properties": {
        "verb": {
          "anyOf": [
            {
              "enum": [
                "get",
                "post",
                "put",
                "delete",
                "patch",
                "head"
              ]
            },
            {
              "type": "string",
              "pattern": "^\\{\\{.+\\}\\}$"
            }
          ],
          "description": "Lowercase HTTP verb; default post. Only post, put and patch send the supplied body."
        },
        "path": {
          "type": "string",
          "minLength": 1,
          "description": "Full HTTP or HTTPS destination URL, including any query string."
        },
        "headers": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": {}
            },
            {
              "type": "string",
              "pattern": "^\\{\\{.+\\}\\}$"
            }
          ],
          "description": "Header names and values. Values are converted to text; declared Secret expressions can supply confidential values."
        },
        "timeout": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "string",
              "pattern": "^\\{\\{.+\\}\\}$"
            }
          ],
          "description": "Positive request timeout in milliseconds; default 30000."
        },
        "async": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "string",
              "pattern": "^\\{\\{.+\\}\\}$"
            }
          ],
          "description": "Default false. True submits asynchronously and returns null, discarding the response."
        }
      }
    },
    "httpSpec": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "request"
      ],
      "properties": {
        "type": {
          "const": "net.http.native"
        },
        "version": {
          "anyOf": [
            {
              "enum": [
                "HTTP_1_1",
                "HTTP_2"
              ]
            },
            {
              "type": "string",
              "pattern": "^\\{\\{.+\\}\\}$"
            }
          ],
          "description": "Default HTTP_1_1."
        },
        "connectTimeout": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "string",
              "pattern": "^\\{\\{.+\\}\\}$"
            }
          ],
          "description": "Positive connection timeout in milliseconds; default 30000."
        },
        "ssl": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "description": "Optional approved key and certificate identifiers from declared Secrets. Uses the default SecretsProvider.",
              "properties": {
                "key": {
                  "type": "string"
                },
                "certificate": {
                  "type": "string"
                },
                "trustCAs": {
                  "anyOf": [
                    {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    {
                      "type": "string",
                      "pattern": "^\\{\\{.+\\}\\}$"
                    }
                  ]
                }
              }
            },
            {
              "type": "string",
              "pattern": "^\\{\\{.+\\}\\}$"
            }
          ]
        },
        "request": {
          "anyOf": [
            {
              "$ref": "#/$defs/httpRequest"
            },
            {
              "type": "string",
              "pattern": "^\\{\\{.+\\}\\}$"
            }
          ]
        }
      }
    }
  }
}
