added self for nameservers for openApi defaults.
This commit is contained in:
parent
d31ee8bdec
commit
753e96ed85
6
TODO
6
TODO
|
@ -1,6 +1,8 @@
|
||||||
|
Cron on all 4 ns.
|
||||||
|
BUG, NS$: No nameserver marked as this server.
|
||||||
|
BUG, NS1: Only one nameserver is designated as our host OK, but all are …
|
||||||
|
panels:apiping on all 4 servers
|
||||||
API Endpint cleanup
|
API Endpint cleanup
|
||||||
API Endpint for version
|
|
||||||
CLI Version check
|
|
||||||
check keytype of panel/bindApi
|
check keytype of panel/bindApi
|
||||||
more UNIT tests
|
more UNIT tests
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "24unix/bindapi",
|
"name": "24unix/bindapi",
|
||||||
"description": "manage Bind9 DNS server via REST API",
|
"description": "manage Bind9 DNS server via REST API",
|
||||||
"version": "1.0.9",
|
"version": "1.0.9",
|
||||||
"build_number": "370",
|
"build_number": "371",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Micha Espey",
|
"name": "Micha Espey",
|
||||||
|
|
|
@ -1681,8 +1681,14 @@ class CLIController
|
||||||
$nameserverList = implode(separator: "', '", array: $nameservers);
|
$nameserverList = implode(separator: "', '", array: $nameservers);
|
||||||
|
|
||||||
$currentDBVersion = $this->settingsRepository->findByName(name: 'version');
|
$currentDBVersion = $this->settingsRepository->findByName(name: 'version');
|
||||||
$dbVersion = json_decode(json: $currentDBVersion);
|
if ($dbVersion = json_decode(json: $currentDBVersion)) {
|
||||||
$versionSting = $dbVersion->version->major . '.' . $dbVersion->version->minor . '.' . $dbVersion->version->patch;
|
$versionSting = $dbVersion->version->major . '.' . $dbVersion->version->minor . '.' . $dbVersion->version->patch;
|
||||||
|
} else {
|
||||||
|
if (!$this->quiet) {
|
||||||
|
echo COLOR_RED . 'Error: ' . COLOR_DEFAULT . 'Check version settings.' . PHP_EOL;
|
||||||
|
}
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$fileContent = "<?php
|
$fileContent = "<?php
|
||||||
|
|
|
@ -10,8 +10,9 @@ use App\Repository\ApikeyRepository;
|
||||||
use App\Repository\DomainRepository;
|
use App\Repository\DomainRepository;
|
||||||
use App\Repository\DynDNSRepository;
|
use App\Repository\DynDNSRepository;
|
||||||
use App\Repository\PanelRepository;
|
use App\Repository\PanelRepository;
|
||||||
|
use App\Service\ApiClient;
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use OpenApi\Attributes as OAT;
|
use OpenApi\Attributes as OA;
|
||||||
use OpenApi\Attributes\OpenApi;
|
use OpenApi\Attributes\OpenApi;
|
||||||
use OpenApi\Generator;
|
use OpenApi\Generator;
|
||||||
use UnhandledMatchError;
|
use UnhandledMatchError;
|
||||||
|
@ -19,27 +20,27 @@ use function Symfony\Component\String\s;
|
||||||
|
|
||||||
// TODO attributes for swaggerUI
|
// TODO attributes for swaggerUI
|
||||||
|
|
||||||
#[OAT\Info(version: VERSION, title: 'bindAPI')]
|
#[OA\Info(version: VERSION, title: 'bindAPI')]
|
||||||
#[OAT\Server(
|
#[OA\Server(
|
||||||
url: "{schema}://{hostname}/api",
|
url: "{schema}://{hostname}/api",
|
||||||
description: "The bindAPI URL.",
|
description: "The bindAPI URL.",
|
||||||
variables: [
|
variables: [
|
||||||
new OAT\ServerVariable(
|
new OA\ServerVariable(
|
||||||
serverVariable: 'schema',
|
serverVariable: 'schema',
|
||||||
default: 'https',
|
default: 'https',
|
||||||
enum: ['http', 'https']
|
enum: ['http', 'https']
|
||||||
),
|
),
|
||||||
new OAT\ServerVariable(
|
new OA\ServerVariable(
|
||||||
serverVariable: 'hostname',
|
serverVariable: 'hostname',
|
||||||
default: DEFAULT_NS,
|
default: DEFAULT_NS,
|
||||||
enum: NAMESERVERS
|
enum: NAMESERVERS
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
)]
|
)]
|
||||||
#[OAT\Tag(
|
#[OA\Tag(
|
||||||
name: "Server"
|
name: "Server"
|
||||||
)]
|
)]
|
||||||
#[OAT\SecurityScheme(
|
#[OA\SecurityScheme(
|
||||||
securityScheme: "Authorization",
|
securityScheme: "Authorization",
|
||||||
type: "apiKey",
|
type: "apiKey",
|
||||||
description: "Api Authentication",
|
description: "Api Authentication",
|
||||||
|
@ -60,7 +61,7 @@ class RequestController
|
||||||
// server tag
|
// server tag
|
||||||
private string $baseDir;
|
private string $baseDir;
|
||||||
|
|
||||||
#[OAT\Get(
|
#[OA\Get(
|
||||||
path: '/ping',
|
path: '/ping',
|
||||||
operationId: 'ping',
|
operationId: 'ping',
|
||||||
description: 'Checks for connectivity and valid APIkey',
|
description: 'Checks for connectivity and valid APIkey',
|
||||||
|
@ -69,11 +70,11 @@ class RequestController
|
||||||
],
|
],
|
||||||
tags: ['Server'],
|
tags: ['Server'],
|
||||||
responses: [
|
responses: [
|
||||||
new OAT\Response(
|
new OA\Response(
|
||||||
response: 200,
|
response: 200,
|
||||||
description: 'OK'
|
description: 'OK'
|
||||||
),
|
),
|
||||||
new OAT\Response(
|
new OA\Response(
|
||||||
response: 401,
|
response: 401,
|
||||||
description: 'API key is missing or invalid.'
|
description: 'API key is missing or invalid.'
|
||||||
)
|
)
|
||||||
|
@ -90,7 +91,7 @@ class RequestController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[OAT\Get(
|
#[OA\Get(
|
||||||
path: '/version',
|
path: '/version',
|
||||||
operationId: 'version',
|
operationId: 'version',
|
||||||
description: 'Check the API version of the nameserver.',
|
description: 'Check the API version of the nameserver.',
|
||||||
|
@ -99,11 +100,11 @@ class RequestController
|
||||||
],
|
],
|
||||||
tags: ['Server'],
|
tags: ['Server'],
|
||||||
responses: [
|
responses: [
|
||||||
new OAT\Response(
|
new OA\Response(
|
||||||
response: 200,
|
response: 200,
|
||||||
description: 'x.y.z, aka major, minor, patch'
|
description: 'x.y.z, aka major, minor, patch'
|
||||||
),
|
),
|
||||||
new OAT\Response(
|
new OA\Response(
|
||||||
response: 401,
|
response: 401,
|
||||||
description: 'API key is missing or invalid.'
|
description: 'API key is missing or invalid.'
|
||||||
)
|
)
|
||||||
|
@ -129,7 +130,7 @@ class RequestController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[OAT\Get(
|
#[OA\Get(
|
||||||
path: '/domains',
|
path: '/domains',
|
||||||
operationId: 'getAllDomains',
|
operationId: 'getAllDomains',
|
||||||
description: 'Returns a list of all domains on this server.',
|
description: 'Returns a list of all domains on this server.',
|
||||||
|
@ -139,15 +140,15 @@ class RequestController
|
||||||
],
|
],
|
||||||
tags: ['Domains'],
|
tags: ['Domains'],
|
||||||
responses: [
|
responses: [
|
||||||
new OAT\Response(
|
new OA\Response(
|
||||||
response: 200,
|
response: 200,
|
||||||
description: 'OK'
|
description: 'OK'
|
||||||
),
|
),
|
||||||
new OAT\Response(
|
new OA\Response(
|
||||||
response: 401,
|
response: 401,
|
||||||
description: 'API key is missing or invalid.'
|
description: 'API key is missing or invalid.'
|
||||||
),
|
),
|
||||||
new OAT\Response(
|
new OA\Response(
|
||||||
response: 404,
|
response: 404,
|
||||||
description: 'Domain not found.'
|
description: 'Domain not found.'
|
||||||
)]
|
)]
|
||||||
|
@ -238,7 +239,7 @@ class RequestController
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#[
|
#[
|
||||||
OAT\Get(
|
OA\Get(
|
||||||
path: '/domains/{name}',
|
path: '/domains/{name}',
|
||||||
operationId: 'getSingleDomain',
|
operationId: 'getSingleDomain',
|
||||||
description: 'Returns information of a single domain specified by its domain name.',
|
description: 'Returns information of a single domain specified by its domain name.',
|
||||||
|
@ -247,18 +248,18 @@ class RequestController
|
||||||
],
|
],
|
||||||
tags: ['Domains'],
|
tags: ['Domains'],
|
||||||
parameters: [
|
parameters: [
|
||||||
new OAT\Parameter(name: 'name', in: 'path', required: true, schema: new OAT\Schema(type: 'string')),
|
new OA\Parameter(name: 'name', in: 'path', required: true, schema: new OA\Schema(type: 'string')),
|
||||||
],
|
],
|
||||||
responses: [
|
responses: [
|
||||||
new OAT\Response(
|
new OA\Response(
|
||||||
response: 200,
|
response: 200,
|
||||||
description: 'OK'
|
description: 'OK'
|
||||||
),
|
),
|
||||||
new OAT\Response(
|
new OA\Response(
|
||||||
response: 401,
|
response: 401,
|
||||||
description: 'API key is missing or invalid.'
|
description: 'API key is missing or invalid.'
|
||||||
),
|
),
|
||||||
new OAT\Response(
|
new OA\Response(
|
||||||
response: 404,
|
response: 404,
|
||||||
description: 'Domain not found.'
|
description: 'Domain not found.'
|
||||||
)]
|
)]
|
||||||
|
@ -653,6 +654,7 @@ class RequestController
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
private readonly ApiClient $apiClient,
|
||||||
private readonly ApikeyRepository $apikeyRepository,
|
private readonly ApikeyRepository $apikeyRepository,
|
||||||
private readonly DomainController $domainController,
|
private readonly DomainController $domainController,
|
||||||
private readonly DomainRepository $domainRepository,
|
private readonly DomainRepository $domainRepository,
|
||||||
|
@ -694,7 +696,7 @@ class RequestController
|
||||||
// domains
|
// domains
|
||||||
'domains' => $this->handleDomains(),
|
'domains' => $this->handleDomains(),
|
||||||
'dyndns' => $this->handleDynDNS(),
|
'dyndns' => $this->handleDynDNS(),
|
||||||
'apidoc' => $this->apiDoc(),
|
// 'apidoc' => $this->apiDoc(),
|
||||||
};
|
};
|
||||||
} catch (UnhandledMatchError) {
|
} catch (UnhandledMatchError) {
|
||||||
$this->status = '400 Bad Request';
|
$this->status = '400 Bad Request';
|
||||||
|
|
|
@ -20,10 +20,8 @@ use Monolog\Formatter\LineFormatter;
|
||||||
use Monolog\Handler\StreamHandler;
|
use Monolog\Handler\StreamHandler;
|
||||||
use Monolog\Level;
|
use Monolog\Level;
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use OpenApi\Attributes as OA;
|
|
||||||
use function DI\autowire;
|
use function DI\autowire;
|
||||||
|
|
||||||
#[OA\Info(version: '1.0.9', title: 'bindAPI')]
|
|
||||||
class BindAPI
|
class BindAPI
|
||||||
{
|
{
|
||||||
private Logger $logger;
|
private Logger $logger;
|
||||||
|
|
Loading…
Reference in New Issue