{
  "openapi": "3.1.0",
  "info": {
    "title": "Gehirn MTA",
    "version": "1"
  },
  "components": {
    "schemas": {
      "Domain": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true
          },
          "name": {
            "type": "string",
            "format": "hostname",
            "readOnly": true
          },
          "quota": {
            "type": "object",
            "properties": {
              "in_minute": {
                "type": "integer",
                "default": 100
              },
              "in_day": {
                "type": "integer",
                "default": 2000
              }
            },
            "readOnly": true
          },
          "usage": {
            "type": "object",
            "properties": {
              "in_minute": {
                "type": "integer",
                "default": 0
              },
              "in_day": {
                "type": "integer",
                "default": 0
              }
            },
            "readOnly": true
          }
        },
        "required": [
          "id",
          "name",
          "quota",
          "usage"
        ]
      },
      "CreateDomainRequest": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string",
            "format": "hostname"
          }
        },
        "required": [
          "domain"
        ]
      },
      "DeleteDomainResponse": {
        "type": "object",
        "properties": {
          "successful": {
            "type": "boolean",
            "default": true
          }
        },
        "required": [
          "successful"
        ]
      },
      "Rule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true
          },
          "class": {
            "$ref": "#/components/schemas/RuleClass",
            "readOnly": true
          },
          "type": {
            "$ref": "#/components/schemas/RuleType",
            "readOnly": true
          },
          "edj_topic_id": {
            "type": "string",
            "readOnly": true
          },
          "account": {
            "type": "string",
            "readOnly": true
          }
        },
        "required": [
          "id",
          "class",
          "type",
          "edj_topic_id"
        ]
      },
      "RuleClass": {
        "enum": [
          "incoming",
          "outgoing",
          "notice"
        ]
      },
      "RuleType": {
        "enum": [
          "direct",
          "all",
          "catchall"
        ]
      },
      "CreateRuleRequest": {
        "type": "object",
        "properties": {
          "class": {
            "$ref": "#/components/schemas/RuleClass"
          },
          "type": {
            "$ref": "#/components/schemas/RuleType"
          },
          "edj_topic_id": {
            "type": "string"
          },
          "account": {
            "type": "string"
          }
        },
        "required": [
          "class",
          "type",
          "edj_topic_id"
        ]
      },
      "DeleteRuleResponse": {
        "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": [
              {
                "$ref": "#/components/schemas/SendMessageResponse"
              },
              {
                "$ref": "#/components/schemas/DKIMStatus"
              }
            ]
          }
        },
        "required": [
          "id",
          "procedure",
          "state",
          "created_at"
        ]
      },
      "ProcedureName": {
        "enum": [
          "send_message",
          "get_dkim_status",
          "enable_dkim",
          "disable_dkim",
          "regenerate_dkim_key"
        ]
      },
      "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/SendMessageRequest"
              }
            ]
          }
        },
        "required": [
          "procedure",
          "arguments"
        ]
      },
      "DKIMStatus": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string"
          },
          "keytype": {
            "type": "string"
          },
          "public": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          }
        },
        "required": [
          "selector",
          "keytype",
          "public",
          "enabled"
        ]
      },
      "SendMessageRequest": {
        "type": "object",
        "properties": {
          "from": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sender": {
            "type": "string"
          },
          "reply_to": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "to": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "cc": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "bcc": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "message_id": {
            "type": "string"
          },
          "in_reply_to": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "references": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "additional_header": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "content_type": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "filename": {
                  "type": "string"
                },
                "content_type": {
                  "type": "string"
                },
                "content": {
                  "type": "string"
                }
              },
              "required": [
                "content_type",
                "content"
              ]
            }
          }
        }
      },
      "SendMessageResponse": {
        "type": "object",
        "properties": {
          "header_list": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "raw_name": {
                  "type": "string"
                },
                "raw_value": {
                  "type": "string"
                }
              },
              "required": [
                "raw_name",
                "raw_value"
              ]
            }
          },
          "header_map": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "body": {
            "type": "string"
          }
        },
        "required": [
          "header_list",
          "header_map",
          "body"
        ]
      }
    },
    "securitySchemes": {
      "static_token_basic": {
        "type": "http",
        "scheme": "basic"
      },
      "static_token_bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/mta/v1/domains": {
      "post": {
        "operationId": "CreateDomain",
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDomainRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "ListDomains",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Domain"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/mta/v1/domains/{domain_id}": {
      "parameters": [
        {
          "name": "domain_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "GetDomain",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "DeleteDomain",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteDomainResponse"
                }
              }
            }
          }
        }
      }
    },
    "/mta/v1/domains/{domain_id}/rules": {
      "parameters": [
        {
          "name": "domain_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "operationId": "CreateRule",
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRuleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Rule"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "ListRules",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Rule"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/mta/v1/domains/{domain_id}/rules/{rule_id}": {
      "parameters": [
        {
          "name": "domain_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "rule_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "GetRule",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Rule"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "DeleteRule",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteRuleResponse"
                }
              }
            }
          }
        }
      }
    },
    "/mta/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"
                }
              }
            }
          }
        }
      }
    },
    "/mta/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": []
    }
  ]
}