added self for nameservers for openApi defaults.
This commit is contained in:
parent
d0224f6746
commit
f25e90f292
148
bindapi.json
Normal file
148
bindapi.json
Normal file
@ -0,0 +1,148 @@
|
||||
{
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"title": "bindAPI",
|
||||
"version": "1.0.9"
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "{schema}://{hostname}/api",
|
||||
"description": "The bindAPI URL.",
|
||||
"variables": {
|
||||
"schema": {
|
||||
"enum": [
|
||||
"http",
|
||||
"https"
|
||||
],
|
||||
"default": "https"
|
||||
},
|
||||
"hostname": {
|
||||
"enum": [
|
||||
"ns1.24unix.net",
|
||||
"ns2.24unix.net"
|
||||
],
|
||||
"default": "ns2.24unix.net"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/ping": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Server"
|
||||
],
|
||||
"description": "Checks for connectivity and valid APIkey",
|
||||
"operationId": "ping",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"401": {
|
||||
"description": "API key is missing or invalid."
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/version": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Server"
|
||||
],
|
||||
"description": "Check the API version of the nameserver.",
|
||||
"operationId": "version",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "x.y.z, aka major, minor, patch"
|
||||
},
|
||||
"401": {
|
||||
"description": "API key is missing or invalid."
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/domains": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "List all domains.",
|
||||
"description": "Returns a list of all domains on this server.",
|
||||
"operationId": "getAllDomains",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"401": {
|
||||
"description": "API key is missing or invalid."
|
||||
},
|
||||
"404": {
|
||||
"description": "Domain not found."
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/domains/{name}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Returns a single domain.",
|
||||
"description": "Returns information of a single domain specified by its domain name.",
|
||||
"operationId": "getSingleDomain",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "name",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"401": {
|
||||
"description": "API key is missing or invalid."
|
||||
},
|
||||
"404": {
|
||||
"description": "Domain not found."
|
||||
}
|
||||
},
|
||||
"security": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"securitySchemes": {
|
||||
"Authorization": {
|
||||
"type": "apiKey",
|
||||
"description": "Api Authentication",
|
||||
"name": "X-API-Key",
|
||||
"in": "header"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "Server"
|
||||
}
|
||||
]
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
"name": "24unix/bindapi",
|
||||
"description": "manage Bind9 DNS server via REST API",
|
||||
"version": "1.0.9",
|
||||
"build_number": "359",
|
||||
"build_number": "361",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Micha Espey",
|
||||
|
@ -1126,6 +1126,30 @@ return array (
|
||||
'IS_GENERATED' => 'NEVER',
|
||||
'GENERATION_EXPRESSION' => NULL,
|
||||
),
|
||||
'self' =>
|
||||
array (
|
||||
'TABLE_CATALOG' => 'def',
|
||||
'TABLE_NAME' => 'nameservers',
|
||||
'COLUMN_NAME' => 'self',
|
||||
'ORDINAL_POSITION' => 7,
|
||||
'COLUMN_DEFAULT' => NULL,
|
||||
'IS_NULLABLE' => 'NO',
|
||||
'DATA_TYPE' => 'enum',
|
||||
'CHARACTER_MAXIMUM_LENGTH' => 3,
|
||||
'CHARACTER_OCTET_LENGTH' => 12,
|
||||
'NUMERIC_PRECISION' => NULL,
|
||||
'NUMERIC_SCALE' => NULL,
|
||||
'DATETIME_PRECISION' => NULL,
|
||||
'CHARACTER_SET_NAME' => 'utf8mb4',
|
||||
'COLLATION_NAME' => 'utf8mb4_unicode_ci',
|
||||
'COLUMN_TYPE' => 'enum(\'yes\',\'no\')',
|
||||
'COLUMN_KEY' => '',
|
||||
'EXTRA' => '',
|
||||
'PRIVILEGES' => 'select,insert,update,references',
|
||||
'COLUMN_COMMENT' => '',
|
||||
'IS_GENERATED' => 'NEVER',
|
||||
'GENERATION_EXPRESSION' => NULL,
|
||||
),
|
||||
),
|
||||
'indexes' =>
|
||||
array (
|
||||
|
@ -1,537 +1,149 @@
|
||||
{
|
||||
"openapi": "3.0.2",
|
||||
"info": {
|
||||
"title": "bindAPI",
|
||||
"version": "0.0.2",
|
||||
"description": "TODO …",
|
||||
"contact": {
|
||||
"name": "Micha Espey",
|
||||
"email": "tracer@24unix.net"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "{schema}://{hostname}/api",
|
||||
"description": "The bindAPI URL.",
|
||||
"variables": {
|
||||
"schema": {
|
||||
"enum": [
|
||||
"https",
|
||||
"http"
|
||||
],
|
||||
"default": "https"
|
||||
},
|
||||
"hostname": {
|
||||
"default": "ns1.24unix.net"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "Server"
|
||||
},
|
||||
{
|
||||
"name": "DNS"
|
||||
},
|
||||
{
|
||||
"name": "Domains"
|
||||
}
|
||||
],
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/ping": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Server"
|
||||
],
|
||||
"summary": "Returning pong.",
|
||||
"description": "Can be used to check API or server availability.",
|
||||
"operationId": "getPong",
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/components/responses/ping"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/401-unauthorized"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": [
|
||||
"read"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/dyndns/{hostname}": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"DNS"
|
||||
],
|
||||
"summary": "Updated a DynDNS host.",
|
||||
"description": "Updates a predefined custom DNS entry.",
|
||||
"operationId": "updateDynDNS",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "hostname",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"$ref": "#/components/requestBodies/dyndns-put"
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
},
|
||||
"401": {
|
||||
"description": "API key is missing or invalid."
|
||||
},
|
||||
"404": {
|
||||
"description": "Domain not found."
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/domains": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Returns all domains.",
|
||||
"description": "Returns information of a single domain specified by its domain name.",
|
||||
"operationId": "getDomains",
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/components/responses/domain-array"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/401-unauthorized"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": [
|
||||
"read"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
"post": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Create a domain.",
|
||||
"description": "Create a new domain.",
|
||||
"operationId": "putDomains",
|
||||
"requestBody": {
|
||||
"$ref": "#/components/requestBodies/domain-post"
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"$ref": "#/components/responses/201-created"
|
||||
},
|
||||
"400": {
|
||||
"$ref": "#/components/responses/400-bad-request"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/401-unauthorized"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/domains/{id}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Returns a single domain.",
|
||||
"description": "Returns information of a single domain specified by its ID.",
|
||||
"operationId": "getSingleDomain",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/components/responses/200-ok"
|
||||
},
|
||||
"400": {
|
||||
"$ref": "#/components/responses/400-bad-request"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/401-unauthorized"
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Updates a domain.",
|
||||
"description": "Updates a domain. Only supplied fields will be updated, existing won't be affected.",
|
||||
"operationId": "putDomain",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"$ref": "#/components/requestBodies/domain-put"
|
||||
},
|
||||
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"401": {
|
||||
"description": "API key is missing or invalid."
|
||||
},
|
||||
"404": {
|
||||
"description": "Domain not found."
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Deletes a domain.",
|
||||
"description": "Deletes a domain.",
|
||||
"operationId": "73c6c14e6d84f759d2e09029cb7ab2be",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"$ref": "#/components/responses/204-no-content"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/401-unauthorized"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/components/responses/404-not-found"
|
||||
}
|
||||
}, "security": [
|
||||
{
|
||||
"Authorization": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/domains/name/{name}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Returns a single domain by name.",
|
||||
"description": "Returns information of a single domain specified by its domain name.",
|
||||
"operationId": "getSingleDomainByName",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "name",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/components/responses/200-ok"
|
||||
},
|
||||
"400": {
|
||||
"$ref": "#/components/responses/400-bad-request"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/401-unauthorized"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"securitySchemes": {
|
||||
"Authorization": {
|
||||
"type": "apiKey",
|
||||
"description": "Authentication Token",
|
||||
"name": "X-API-Key",
|
||||
"in": "header"
|
||||
}
|
||||
},
|
||||
"requestBodies": {
|
||||
"dyndns-put": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/dyndns"
|
||||
},
|
||||
"example": {
|
||||
"a": "1.2.3.4",
|
||||
"aaaa": "1bad::babe"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain-post": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/domain"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain-put": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/domain"
|
||||
},
|
||||
"example": {
|
||||
"name": "example.com",
|
||||
"panel_id": "8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"ping": {
|
||||
"description": "OK.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ping"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain": {
|
||||
"description": "OK.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/domain"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain-array": {
|
||||
"description": "OK.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/domain"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"200-ok": {
|
||||
"description": "OK."
|
||||
},
|
||||
"200-ok-updated": {
|
||||
"description": "OK.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/created"
|
||||
},
|
||||
"example": {
|
||||
"id": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"201-created": {
|
||||
"description": "Created.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/created"
|
||||
},
|
||||
"example": {
|
||||
"id": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"204-no-content": {
|
||||
"description": "No content."
|
||||
},
|
||||
"400-bad-request": {
|
||||
"description": "Bad request.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/error"
|
||||
},
|
||||
"example": {
|
||||
"code": "400 Bad Request",
|
||||
"message": "Invalid request body."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401-unauthorized": {
|
||||
"description": "Unauthorized.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/error"
|
||||
},
|
||||
"example": {
|
||||
"code": "401 Unauthorized",
|
||||
"message": "API key is missing or invalid."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404-not-found": {
|
||||
"description": "The specified resource was not found.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/error"
|
||||
},
|
||||
"example": {
|
||||
"code": "404 Not Found",
|
||||
"message": "The specified resource was not found."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"schemas": {
|
||||
"ping": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"response": {
|
||||
"type": "string",
|
||||
"example": "pong"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dyndns": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"a": {
|
||||
"type": "string",
|
||||
"example": "1.2.3.4"
|
||||
},
|
||||
"aaaa": {
|
||||
"type": "string",
|
||||
"example": "1bad::babe"
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
"domain": {
|
||||
"description": "Representation of a domain.\n",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"readOnly": true,
|
||||
"description": "The ID of the domain.",
|
||||
"example": 8
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "The ASCII representation of the domain.",
|
||||
"example": "example.com"
|
||||
},
|
||||
"panel_id": {
|
||||
"type": "integer",
|
||||
"description": "The KeyHelp Panel ID. Either this or at least one IP address is required",
|
||||
"example": 4
|
||||
},
|
||||
"a": {
|
||||
"type": "string",
|
||||
"readOnly": true,
|
||||
"description": "The IPv4 address.",
|
||||
"example": "12.13.14.15"
|
||||
},
|
||||
"aaaa": {
|
||||
"type": "string",
|
||||
"readOnly": true,
|
||||
"description": "The IPv6 address.",
|
||||
"example": "1bad::babe"
|
||||
}
|
||||
}
|
||||
},
|
||||
"created": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"code",
|
||||
"message#"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"title": "bindAPI",
|
||||
"version": "1.0.9"
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "{schema}://{hostname}/api",
|
||||
"description": "The bindAPI URL.",
|
||||
"variables": {
|
||||
"schema": {
|
||||
"enum": [
|
||||
"http",
|
||||
"https"
|
||||
],
|
||||
"default": "https"
|
||||
},
|
||||
"hostname": {
|
||||
"enum": [
|
||||
"ns1.24unix.net",
|
||||
"ns2.24unix.net",
|
||||
"ns3.24unix.net"
|
||||
],
|
||||
"default": "ns2.24unix.net"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/ping": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Server"
|
||||
],
|
||||
"description": "Checks for connectivity and valid APIkey",
|
||||
"operationId": "ping",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"401": {
|
||||
"description": "API key is missing or invalid."
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/version": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Server"
|
||||
],
|
||||
"description": "Check the API version of the nameserver.",
|
||||
"operationId": "version",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "x.y.z, aka major, minor, patch"
|
||||
},
|
||||
"401": {
|
||||
"description": "API key is missing or invalid."
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/domains": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "List all domains.",
|
||||
"description": "Returns a list of all domains on this server.",
|
||||
"operationId": "getAllDomains",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"401": {
|
||||
"description": "API key is missing or invalid."
|
||||
},
|
||||
"404": {
|
||||
"description": "Domain not found."
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/domains/{name}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Returns a single domain.",
|
||||
"description": "Returns information of a single domain specified by its domain name.",
|
||||
"operationId": "getSingleDomain",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "name",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"401": {
|
||||
"description": "API key is missing or invalid."
|
||||
},
|
||||
"404": {
|
||||
"description": "Domain not found."
|
||||
}
|
||||
},
|
||||
"security": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"securitySchemes": {
|
||||
"Authorization": {
|
||||
"type": "apiKey",
|
||||
"description": "Api Authentication",
|
||||
"name": "X-API-Key",
|
||||
"in": "header"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "Server"
|
||||
}
|
||||
]
|
||||
}
|
537
public/openapi/bindapi.json.bak
Normal file
537
public/openapi/bindapi.json.bak
Normal file
@ -0,0 +1,537 @@
|
||||
{
|
||||
"openapi": "3.0.2",
|
||||
"info": {
|
||||
"title": "bindAPI",
|
||||
"version": "0.0.2",
|
||||
"description": "TODO …",
|
||||
"contact": {
|
||||
"name": "Micha Espey",
|
||||
"email": "tracer@24unix.net"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "{schema}://{hostname}/api",
|
||||
"description": "The bindAPI URL.",
|
||||
"variables": {
|
||||
"schema": {
|
||||
"enum": [
|
||||
"https",
|
||||
"http"
|
||||
],
|
||||
"default": "https"
|
||||
},
|
||||
"hostname": {
|
||||
"default": "ns1.24unix.net"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "Server"
|
||||
},
|
||||
{
|
||||
"name": "DNS"
|
||||
},
|
||||
{
|
||||
"name": "Domains"
|
||||
}
|
||||
],
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/ping": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Server"
|
||||
],
|
||||
"summary": "Returning pong.",
|
||||
"description": "Can be used to check API or server availability.",
|
||||
"operationId": "getPong",
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/components/responses/ping"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/401-unauthorized"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": [
|
||||
"read"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/dyndns/{hostname}": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"DNS"
|
||||
],
|
||||
"summary": "Updated a DynDNS host.",
|
||||
"description": "Updates a predefined custom DNS entry.",
|
||||
"operationId": "updateDynDNS",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "hostname",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"$ref": "#/components/requestBodies/dyndns-put"
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
},
|
||||
"401": {
|
||||
"description": "API key is missing or invalid."
|
||||
},
|
||||
"404": {
|
||||
"description": "Domain not found."
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/domains": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Returns all domains.",
|
||||
"description": "Returns information of a single domain specified by its domain name.",
|
||||
"operationId": "getDomains",
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/components/responses/domain-array"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/401-unauthorized"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": [
|
||||
"read"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
"post": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Create a domain.",
|
||||
"description": "Create a new domain.",
|
||||
"operationId": "putDomains",
|
||||
"requestBody": {
|
||||
"$ref": "#/components/requestBodies/domain-post"
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"$ref": "#/components/responses/201-created"
|
||||
},
|
||||
"400": {
|
||||
"$ref": "#/components/responses/400-bad-request"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/401-unauthorized"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/domains/{id}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Returns a single domain.",
|
||||
"description": "Returns information of a single domain specified by its ID.",
|
||||
"operationId": "getSingleDomain",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/components/responses/200-ok"
|
||||
},
|
||||
"400": {
|
||||
"$ref": "#/components/responses/400-bad-request"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/401-unauthorized"
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Updates a domain.",
|
||||
"description": "Updates a domain. Only supplied fields will be updated, existing won't be affected.",
|
||||
"operationId": "putDomain",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"$ref": "#/components/requestBodies/domain-put"
|
||||
},
|
||||
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
},
|
||||
"401": {
|
||||
"description": "API key is missing or invalid."
|
||||
},
|
||||
"404": {
|
||||
"description": "Domain not found."
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Authorization": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Deletes a domain.",
|
||||
"description": "Deletes a domain.",
|
||||
"operationId": "73c6c14e6d84f759d2e09029cb7ab2be",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"$ref": "#/components/responses/204-no-content"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/401-unauthorized"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/components/responses/404-not-found"
|
||||
}
|
||||
}, "security": [
|
||||
{
|
||||
"Authorization": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/domains/name/{name}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Domains"
|
||||
],
|
||||
"summary": "Returns a single domain by name.",
|
||||
"description": "Returns information of a single domain specified by its domain name.",
|
||||
"operationId": "getSingleDomainByName",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "name",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/components/responses/200-ok"
|
||||
},
|
||||
"400": {
|
||||
"$ref": "#/components/responses/400-bad-request"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/401-unauthorized"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"securitySchemes": {
|
||||
"Authorization": {
|
||||
"type": "apiKey",
|
||||
"description": "Authentication Token",
|
||||
"name": "X-API-Key",
|
||||
"in": "header"
|
||||
}
|
||||
},
|
||||
"requestBodies": {
|
||||
"dyndns-put": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/dyndns"
|
||||
},
|
||||
"example": {
|
||||
"a": "1.2.3.4",
|
||||
"aaaa": "1bad::babe"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain-post": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/domain"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain-put": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/domain"
|
||||
},
|
||||
"example": {
|
||||
"name": "example.com",
|
||||
"panel_id": "8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"ping": {
|
||||
"description": "OK.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ping"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain": {
|
||||
"description": "OK.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/domain"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"domain-array": {
|
||||
"description": "OK.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/domain"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"200-ok": {
|
||||
"description": "OK."
|
||||
},
|
||||
"200-ok-updated": {
|
||||
"description": "OK.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/created"
|
||||
},
|
||||
"example": {
|
||||
"id": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"201-created": {
|
||||
"description": "Created.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/created"
|
||||
},
|
||||
"example": {
|
||||
"id": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"204-no-content": {
|
||||
"description": "No content."
|
||||
},
|
||||
"400-bad-request": {
|
||||
"description": "Bad request.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/error"
|
||||
},
|
||||
"example": {
|
||||
"code": "400 Bad Request",
|
||||
"message": "Invalid request body."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401-unauthorized": {
|
||||
"description": "Unauthorized.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/error"
|
||||
},
|
||||
"example": {
|
||||
"code": "401 Unauthorized",
|
||||
"message": "API key is missing or invalid."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404-not-found": {
|
||||
"description": "The specified resource was not found.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/error"
|
||||
},
|
||||
"example": {
|
||||
"code": "404 Not Found",
|
||||
"message": "The specified resource was not found."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"schemas": {
|
||||
"ping": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"response": {
|
||||
"type": "string",
|
||||
"example": "pong"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dyndns": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"a": {
|
||||
"type": "string",
|
||||
"example": "1.2.3.4"
|
||||
},
|
||||
"aaaa": {
|
||||
"type": "string",
|
||||
"example": "1bad::babe"
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
"domain": {
|
||||
"description": "Representation of a domain.\n",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"readOnly": true,
|
||||
"description": "The ID of the domain.",
|
||||
"example": 8
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "The ASCII representation of the domain.",
|
||||
"example": "example.com"
|
||||
},
|
||||
"panel_id": {
|
||||
"type": "integer",
|
||||
"description": "The KeyHelp Panel ID. Either this or at least one IP address is required",
|
||||
"example": 4
|
||||
},
|
||||
"a": {
|
||||
"type": "string",
|
||||
"readOnly": true,
|
||||
"description": "The IPv4 address.",
|
||||
"example": "12.13.14.15"
|
||||
},
|
||||
"aaaa": {
|
||||
"type": "string",
|
||||
"readOnly": true,
|
||||
"description": "The IPv6 address.",
|
||||
"example": "1bad::babe"
|
||||
}
|
||||
}
|
||||
},
|
||||
"created": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"code",
|
||||
"message#"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
const DEFAULT_NS = 'ns2.24unix.net';
|
||||
const NAMESERVERS = ['ns1.24unix.net', 'ns2.24unix.net', 'ns3.24unix.net'];
|
||||
const VERSION = '1.0.9';
|
||||
|
5
public/openapi/bootstrap.php2
Normal file
5
public/openapi/bootstrap.php2
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
const DEFAULT_NS = 'ns2.24unix.net';
|
||||
|
||||
const NAMESERVERS = ['ns1.24unix.net', 'ns2.24unix.net'];
|
@ -21,7 +21,7 @@
|
||||
// Begin Swagger UI call region
|
||||
let ui;
|
||||
ui = SwaggerUIBundle({
|
||||
url: "/app/apidoc",
|
||||
url: "/openapi/bindapi.json",
|
||||
dom_id: "#swagger-ui",
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
|
@ -47,12 +47,13 @@ class CLIController
|
||||
{
|
||||
private array $arguments;
|
||||
private CommandGroupContainer $commandGroupContainer;
|
||||
private string $baseDir;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly ApiClient $apiClient,
|
||||
private readonly ApiClient $apiClient,
|
||||
private readonly ApikeyRepository $apikeyRepository,
|
||||
private readonly DomainController $domainController,
|
||||
private readonly DomainRepository $domainRepository,
|
||||
@ -66,6 +67,8 @@ class CLIController
|
||||
private readonly bool $quiet
|
||||
)
|
||||
{
|
||||
$this->baseDir = dirname(path: __DIR__, levels: 2) . '/';
|
||||
|
||||
$this->commandGroupContainer = (new CommandGroupContainer())
|
||||
->addCommandGroup(commandGroup: (new CommandGroup(name: 'apikeys', description: 'API keys to access this bindAPI'))
|
||||
->addCommand(command: new Command(
|
||||
@ -120,6 +123,12 @@ class CLIController
|
||||
$this->checkPanels();
|
||||
},
|
||||
optionalParameters: ['ID', 'fix=xes']))
|
||||
->addCommand(command: new Command(
|
||||
name: 'nameserver',
|
||||
callback: function () {
|
||||
$this->checkNameserver();
|
||||
},
|
||||
description: 'Validate setting for this panel'))
|
||||
->addCommand(command: new Command(
|
||||
name: 'domains',
|
||||
callback: function () {
|
||||
@ -168,7 +177,7 @@ class CLIController
|
||||
$this->panelsCreate();
|
||||
},
|
||||
mandatoryParameters: ['name'],
|
||||
optionalParameters: ['A=<IPv4>', 'AAAA=<IPv6>', 'apikey=<API-Key>']))
|
||||
optionalParameters: ['A=<IPv4>', 'AAAA=<IPv6>', 'apikey=<API-Key>', 'self=<yes|no>']))
|
||||
->addCommand(command: new Command(
|
||||
name: 'update',
|
||||
callback: function () {
|
||||
@ -348,7 +357,6 @@ class CLIController
|
||||
$this->logger->debug(message: "showUsage()");
|
||||
|
||||
$debug = $this->configController->getConfig(configKey: 'debug');
|
||||
echo COLOR_DEFAULT . ')' . PHP_EOL;
|
||||
|
||||
echo COLOR_YELLOW . 'Usage:' . PHP_EOL;
|
||||
echo COLOR_DEFAULT . "\t./bin/console {options} {arguments}" . PHP_EOL . PHP_EOL;
|
||||
@ -952,6 +960,7 @@ class CLIController
|
||||
|
||||
}
|
||||
|
||||
// FIXME check validation state of panel and nameserver keys
|
||||
var_dump($prefix, $key);
|
||||
echo 'Length of prefix: ' . strlen($prefix) . PHP_EOL;
|
||||
echo 'Length of key: ' . strlen($key) . PHP_EOL;
|
||||
@ -1132,8 +1141,6 @@ class CLIController
|
||||
if ($result['data'] == 'pong') {
|
||||
echo ' ' . COLOR_GREEN . $result['data'];
|
||||
} else {
|
||||
var_dump($result);
|
||||
die;
|
||||
echo COLOR_BLUE . ' xxskip' . COLOR_DEFAULT;
|
||||
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
||||
echo ' ' . $result['data'];
|
||||
@ -1549,28 +1556,72 @@ class CLIController
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$self = $this->arguments['self'] ?? '';
|
||||
|
||||
if ($this->nameserverRepository->findByName(name: $name)) {
|
||||
echo "Nameserver: $name already exists." . PHP_EOL;
|
||||
exit(1);
|
||||
} else {
|
||||
$nameserver = new Nameserver(name: $name, a: $a, aaaa: $aaaa, passphrase: $apikey);
|
||||
$nameserver = new Nameserver(name: $name, a: $a, aaaa: $aaaa, passphrase: $apikey, self: $self);
|
||||
$result = $this->nameserverRepository->insert(nameserver: $nameserver);
|
||||
echo 'Nameserver ' . COLOR_YELLOW . $name . COLOR_DEFAULT . ' has been created with id ' . COLOR_YELLOW . $result . COLOR_DEFAULT . PHP_EOL;
|
||||
$this->createOpenAPIBootstrap();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME add method create bootstrap php, add it to create, delete and update nameservers
|
||||
|
||||
public function createOpenAPIBootstrap()
|
||||
{
|
||||
$basePath = $this->baseDir . '/public/openapi/';
|
||||
|
||||
$bootStrapFile = $basePath . 'bootstrap.php';
|
||||
$allNameservers = $this->nameserverRepository->findAll();
|
||||
|
||||
$nameservers = [];
|
||||
$defaultNS = '';
|
||||
|
||||
foreach ($allNameservers as $ns) {
|
||||
$nameservers[] = $ns->getName();
|
||||
if ($ns->getSelf() === 'yes') {
|
||||
$defaultNS = $ns->getName();
|
||||
}
|
||||
}
|
||||
|
||||
// Improvement in generating file content
|
||||
$nameserverList = implode(separator: "', '", array: $nameservers);
|
||||
|
||||
$currentDBVersion = $this->settingsRepository->findByName(name: 'version');
|
||||
$dbVersion = json_decode(json: $currentDBVersion);
|
||||
$versionSting = $dbVersion->version->major . '.' . $dbVersion->version->minor . '.' . $dbVersion->version->patch;
|
||||
|
||||
|
||||
$fileContent = "<?php
|
||||
|
||||
const DEFAULT_NS = '{$defaultNS}';
|
||||
const NAMESERVERS = ['{$nameserverList}'];
|
||||
const VERSION = '{$versionSting}';
|
||||
" . PHP_EOL;
|
||||
|
||||
try {
|
||||
file_put_contents(filename: $bootStrapFile, data: $fileContent);
|
||||
} catch (Exception $e) {
|
||||
if (!$this->quiet) {
|
||||
echo 'Error: ' . $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
}
|
||||
shell_exec(command: $this->baseDir . 'vendor/bin/openapi src/Controller/RequestController.php -b public/openapi/bootstrap.php -o public/openapi/bindapi.json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
function nameserversList(): void
|
||||
{
|
||||
$nameservers = $this->nameserverRepository->findAll();
|
||||
if (!empty($nameservers)) {
|
||||
echo 'All available nameservers:' . PHP_EOL;
|
||||
$table = new ConsoleTable();
|
||||
$table->setHeaders(content: ['ID', 'Name', 'A', 'AAAA', 'API Key']);
|
||||
$table->setHeaders(content: ['ID', 'Name', 'A', 'AAAA', 'API Key', 'self']);
|
||||
|
||||
foreach ($nameservers as $nameserver) {
|
||||
$row = [];
|
||||
$row[] = $nameserver->getId();
|
||||
@ -1578,6 +1629,7 @@ class CLIController
|
||||