{
  "openapi": "3.1.0",
  "info": {
    "title": "Gehirn EDJ",
    "version": "1"
  },
  "components": {
    "schemas": {
      "Topic": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true
          },
          "name": {
            "type": "string"
          },
          "usage": {
            "type": "integer",
            "format": "int64",
            "default": 0,
            "readOnly": true
          }
        },
        "required": [
          "id",
          "name",
          "usage"
        ]
      },
      "CreateTopicRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          }
        },
        "required": [
          "name"
        ]
      },
      "DeleteTopicResponse": {
        "type": "object",
        "properties": {
          "successful": {
            "type": "boolean",
            "default": true
          }
        },
        "required": [
          "successful"
        ]
      },
      "Subscriber": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true
          },
          "service": {
            "$ref": "#/components/schemas/SubscriberService",
            "readOnly": true
          },
          "action": {
            "$ref": "#/components/schemas/SubscriberAction",
            "readOnly": true
          },
          "disabled": {
            "type": "boolean",
            "default": false,
            "readOnly": true
          },
          "preference": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PreferenceHTTP"
              },
              {
                "$ref": "#/components/schemas/PreferenceMTA"
              },
              {
                "$ref": "#/components/schemas/PreferencePushover"
              },
              {
                "$ref": "#/components/schemas/PreferenceSlack"
              }
            ],
            "readOnly": true
          }
        },
        "required": [
          "id",
          "service",
          "action",
          "disabled",
          "preference"
        ]
      },
      "SubscriberService": {
        "enum": [
          "http",
          "mta",
          "pushover",
          "slack"
        ]
      },
      "SubscriberAction": {
        "enum": [
          "post",
          "send",
          "sms"
        ]
      },
      "PreferenceHTTP": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "secret": {
            "type": "string"
          }
        },
        "required": [
          "url",
          "secret"
        ]
      },
      "PreferenceMTA": {
        "type": "object",
        "properties": {
          "domain_id": {
            "type": "string"
          },
          "account": {
            "type": "string"
          },
          "to": {
            "type": "string",
            "format": "email"
          }
        },
        "required": [
          "domain_id",
          "account",
          "to"
        ]
      },
      "PreferencePushover": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string"
          }
        },
        "required": [
          "token"
        ]
      },
      "PreferenceSlack": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "url"
        ]
      },
      "CreateSubscriberRequest": {
        "type": "object",
        "properties": {
          "service": {
            "$ref": "#/components/schemas/SubscriberService"
          },
          "action": {
            "$ref": "#/components/schemas/SubscriberAction"
          },
          "preference": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PreferenceHTTP"
              },
              {
                "$ref": "#/components/schemas/PreferenceMTA"
              },
              {
                "$ref": "#/components/schemas/PreferencePushover"
              },
              {
                "$ref": "#/components/schemas/PreferenceSlack"
              }
            ]
          }
        },
        "required": [
          "service",
          "action",
          "preference"
        ]
      },
      "DeleteSubscriberResponse": {
        "type": "object",
        "properties": {
          "successful": {
            "type": "boolean",
            "default": true
          },
          "required": [
            "successful"
          ]
        }
      },
      "Task": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "procedure": {
            "$ref": "#/components/schemas/ProcedureName"
          },
          "state": {
            "enum": [
              1,
              2,
              3,
              4,
              5
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "result": {
            "oneOf": [
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "procedure",
          "state",
          "created_at"
        ]
      },
      "ProcedureName": {
        "enum": [
          "publish"
        ]
      },
      "CreateTaskRequest": {
        "type": "object",
        "properties": {
          "procedure": {
            "$ref": "#/components/schemas/ProcedureName"
          },
          "arguments": {
            "type": "object",
            "properties": {
              "self": {
                "type": "string",
                "format": "uri"
              }
            },
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false
              },
              {
                "$ref": "#/components/schemas/PublishRequest"
              }
            ]
          }
        },
        "required": [
          "procedure",
          "arguments"
        ]
      },
      "PublishRequest": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "securitySchemes": {
      "static_token_basic": {
        "type": "http",
        "scheme": "basic"
      },
      "static_token_bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/edj/v1/topics": {
      "post": {
        "operationId": "CreateTopic",
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTopicRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Topic"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "ListTopics",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Topic"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/edj/v1/topics/{topic_id}": {
      "parameters": [
        {
          "name": "topic_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "GetTopic",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Topic"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "DeleteTopic",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteTopicResponse"
                }
              }
            }
          }
        }
      }
    },
    "/edj/v1/topics/{topic_id}/subscribers": {
      "parameters": [
        {
          "name": "topic_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "operationId": "CreateSubscriber",
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSubscriberRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscriber"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "ListSubscribers",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Subscriber"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/edj/v1/topics/{topic_id}/subscribers/{subscriber_id}": {
      "parameters": [
        {
          "name": "topic_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "subscriber_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "GetSubscriber",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscriber"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "DeleteSubscriber",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteSubscriberResponse"
                }
              }
            }
          }
        }
      }
    },
    "/edj/v1/tasks": {
      "post": {
        "operationId": "CreateTask",
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTaskRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          }
        }
      }
    },
    "/edj/v1/tasks/{task_id}": {
      "parameters": [
        {
          "name": "task_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "GetTask",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "static_token_basic": []
    },
    {
      "static_token_bearer": []
    }
  ]
}