{
  "openapi": "3.0.0",
  "info": {
    "description": "An API to facilitate client device enrollment with WireGuard VPN",
    "version": "1.0.0",
    "title": "ordig-api",
    "license": {
      "name": "MIT",
      "url": "https://opensource.org/licenses/MIT"
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "paths": {
    "/api/v1/devices/{hostname}/config": {
      "post": {
        "summary": "Get client device config",
        "description": "Client can get it's own device config using shared secrets",
        "parameters": [
          {
            "name": "hostname",
            "in": "path",
            "description": "The device hostname",
            "required": true,
            "style": "simple",
            "explode": "false,",
            "schema": {
              "type": "string",
              "example": "nick-desktop"
            }
          }
        ],
        "requestBody": {
          "description": "Client generated shared secret",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "example": "m0akoqv43ybi4jf0fpsg13du33vcnm66"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "succeeded": {
                      "type": "boolean",
                      "example": true
                    },
                    "name": {
                      "type": "string",
                      "example": "wg0"
                    },
                    "namespace": {
                      "type": "string",
                      "example": "example.com"
                    },
                    "nameserver": {
                      "type": "string",
                      "example": "10.10.10.10"
                    },
                    "config": {
                      "type": "string",
                      "example": "[Interface]\nAddress = 192.168.8.10/24\nPrivateKey = somethingsecret\nListenPort = 51820\n\n[Peer]\nPublicKey = sZ9CyTvzsE502XPYBZaUuahrh043TUTt57+wzEYPZH4=\nAllowedIPs = 192.168.8.1/24\nEndpoint = wg.example.com:51820\nPersistentKeepalive = 25\n"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "example": "bad request"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "example": "invalid token"
                }
              }
            }
          },
          "500": {
            "description": "error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "example": "some error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/server/devices": {
      "get": {
        "summary": "Get all device configs",
        "description": "The server gets a list of all the client configs",
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "succeeded": {
                      "type": "boolean",
                      "example": true
                    },
                    "configs": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "ip": {
                            "type": "string",
                            "example": "192.168.0.2"
                          },
                          "public_key": {
                            "type": "string",
                            "example": "nIxqi6pp9CMEINeJOFOA31mEajKKkzMZC9DOin52pGs="
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "example": "bad request"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "example": "invalid token"
                }
              }
            }
          },
          "500": {
            "description": "error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "example": "some error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "api_key": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "psk"
      }
    }
  }
}