{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "BORDER PX1 API",
    "description": "BORDER PX1 API descriptions",
    "license": {
      "name": "MIT",
      "url": "https://opensource.org/licenses/MIT"
    }
  },
  "servers": [
    {
      "url": "http://localhost:8888",
      "description": "Development server"
    },
    {
      "url": "https://border-px1-api.herokuapp.com",
      "description": "Test server"
    },
    {
      "url": "https://bpx-api.icu",
      "description": "Production server"
    }
  ],
  "paths": {
    "/user/login": {
      "post": {
        "tags": [
          "USER"
        ],
        "summary": "Login to White Labels Management site",
        "description": "Login white label management site",
        "requestBody": {
          "description": "the password use to login border-px1-api",
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "password": {
                    "type": "string"
                  }
                },
                "required": [
                  "password"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Login response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/loginResponse"
                }
              }
            }
          }
        }
      }
    },
    "/user/login/status": {
      "get": {
        "tags": [
          "USER"
        ],
        "summary": "Check has the user logged in yet",
        "parameters": [
          {
            "name": "border-px1-api",
            "in": "cookie",
            "required": true,
            "description": "The cookie of border-px1-api",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Login Status response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/loginStatusResponse"
                }
              }
            }
          }
        }
      }
    },
    "/authentication/": {
      "post": {
        "tags": [
          "BORDER PX1"
        ],
        "summary": "Login to BORDER-PX1 site",
        "description": "Login BORDER PX1 site by its account",
        "requestBody": {
          "description": "A encrypted string from username & password & url of BORDER PX1(encrypted RSA algorithm)",
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "authenticationData": {
                    "type": "string"
                  }
                },
                "required": [
                  "authenticationData"
                ]
              }
            }
          }
        },
        "security": [],
        "responses": {
          "200": {
            "description": "login successfully",
            "headers": {
              "Set-Cookie": {
                "schema": {
                  "type": "string",
                  "example": "border-px1=abcde12345; Path=/; HttpOnly"
                },
                "description": "a cookie string of border-px1 site"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/authenticationResponse"
                }
              }
            }
          }
        }
      }
    },
    "/authentication/status": {
      "get": {
        "tags": [
          "BORDER PX1"
        ],
        "summary": "Check whether the BORDER PX1 cookie has expired yet",
        "description": "Check whether the BORDER PX1 cookie has expired yet",
        "parameters": [
          {
            "name": "border-px1",
            "in": "cookie",
            "required": true,
            "description": "The authenticated cookie",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Status of cookie",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/authenticationStatusResponse"
                }
              }
            }
          }
        }
      }
    },
    "/info/backendId/{domainType}/{serverIp}": {
      "post": {
        "tags": [
          "INFO"
        ],
        "summary": "Create a backendId for browsing page to specific server",
        "parameters": [
          {
            "name": "domainType",
            "in": "path",
            "required": true,
            "description": "Type of domain",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "serverIp",
            "in": "path",
            "required": true,
            "description": "ID of server",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "border-px1",
            "in": "cookie",
            "required": true,
            "description": "aunthenticated cookie",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get backendId successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/backendIdResponse"
                }
              }
            }
          }
        }
      }
    },
    "/info/server/{domainType}/{siteName}": {
      "get": {
        "tags": [
          "INFO"
        ],
        "summary": "Create a backendId for browsing page to specific server",
        "parameters": [
          {
            "name": "domainType",
            "in": "path",
            "required": true,
            "description": "Type of domain",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "siteName",
            "in": "path",
            "required": true,
            "description": "name of site. Ex: whitelabelname.bpx",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "border-px1",
            "in": "cookie",
            "required": true,
            "description": "aunthenticated cookie from border px1",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get backendId successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServersResponse"
                }
              }
            }
          }
        }
      }
    },
    "/info/domain/{domainType}/{siteName}": {
      "get": {
        "tags": [
          "INFO"
        ],
        "summary": "Get all domains name of site name, site name is a decoded base64 string",
        "parameters": [
          {
            "name": "domainType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "siteName",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get domains successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/domainResponse"
                }
              }
            }
          }
        }
      }
    },
    "/info/valid-domain/{client}/{domainType}/{whitelabelName}": {
      "get": {
        "tags": [
          "INFO"
        ],
        "summary": "Get valid domain ip/name of whitelabel name",
        "parameters": [
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "domainType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "whitelabelName",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get domain successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/validDomainResponse"
                }
              }
            }
          }
        }
      }
    },
    "/info/valid-domain/{client}/{domainType}": {
      "post": {
        "tags": [
          "INFO"
        ],
        "summary": "Update valid domains",
        "description": "Update valid domains for each client and domain type",
        "requestBody": {
          "description": "The json key value, key is name whitelabel name, value is valid domain",
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "domains": {
                    "type": "string"
                  }
                },
                "required": [
                  "domains"
                ]
              }
            }
          }
        },
        "parameters": [
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "domainType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Update successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/validDomainResponse"
                }
              }
            }
          }
        }
      }
    },
    "/info/folder/": {
      "get": {
        "tags": [
          "INFO"
        ],
        "summary": "Get folder by doman",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "description": "url of white label",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get folder successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FolderResponse"
                }
              }
            }
          }
        }
      }
    },
    "/info/temppage/": {
      "get": {
        "tags": [
          "INFO"
        ],
        "summary": "Get tenmp page by domain",
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": true,
            "description": "url of white label",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get temppage successfully",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "FolderResponse": {
        "required": [
          "success"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "path": {
            "type": "string"
          },
          "modifiedDateOfBKFile": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "backendIdResponse": {
        "required": [
          "success"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "backendId": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "authenticationResponse": {
        "required": [
          "success"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "cookie": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "authenticationStatusResponse": {
        "required": [
          "status"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          }
        }
      },
      "authenticatedCookieResponse": {
        "required": [
          "border-px1"
        ],
        "properties": {
          "border-px1": {
            "type": "string"
          }
        }
      },
      "loginResponse": {
        "required": [
          "success"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "token": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "loginStatusResponse": {
        "required": [
          "success"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Server": {
        "properties": {
          "ID": {
            "type": "integer",
            "format": "int32"
          },
          "Addr": {
            "type": "string"
          },
          "Name": {
            "type": "string"
          }
        }
      },
      "ServersResponse": {
        "required": [
          "success",
          "Servers"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "servers": {
            "type": "array",
            "items": {
              "type": "object",
              "schema": {
                "$ref": "#/components/schemas/FolderResponse"
              }
            }
          }
        },
        "example": {
          "success": true,
          "servers": [
            {
              "ID": "79",
              "Addr": "202.95.4.130",
              "Name": "P01-CTG-130"
            },
            {
              "ID": "80",
              "Addr": "103.230.145.4",
              "Name": "P01-GGB-4"
            },
            {
              "ID": "81",
              "Addr": "103.254.109.2",
              "Name": "P01-SUN-2"
            }
          ]
        }
      },
      "domainResponse": {
        "required": [
          "ID",
          "Domain",
          "LastUpdate"
        ],
        "properties": {
          "ID": {
            "type": "number",
            "uniqueItems": true
          },
          "Domain": {
            "type": "string"
          },
          "EnableWWW": {
            "type": "number"
          },
          "RootValid": {
            "type": "number"
          },
          "HTTPS": {
            "type": "number"
          },
          "LastUpdate": {
            "type": "string"
          },
          "ServerTime": {
            "type": "string"
          },
          "LastChecked": {
            "type": "string"
          }
        }
      },
      "validDomainResponse": {
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  }
}
