added chekcs for cron job
This commit is contained in:
parent
5d2e95ac3d
commit
f04c306f91
|
@ -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": "373",
|
"build_number": "374",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Micha Espey",
|
"name": "Micha Espey",
|
||||||
|
|
|
@ -57,7 +57,6 @@ class RequestController
|
||||||
private array $uri;
|
private array $uri;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// server tag
|
// server tag
|
||||||
private string $baseDir;
|
private string $baseDir;
|
||||||
|
|
||||||
|
@ -110,7 +109,6 @@ class RequestController
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
)]
|
)]
|
||||||
|
|
||||||
private function getVersion(): void
|
private function getVersion(): void
|
||||||
{
|
{
|
||||||
if ($this->validateApiKey()) {
|
if ($this->validateApiKey()) {
|
||||||
|
@ -193,79 +191,7 @@ class RequestController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @OA\Tag(name = "Server")
|
|
||||||
* @OA\Get(
|
|
||||||
* path = "/ping",
|
|
||||||
* summary = "Returning pong.",
|
|
||||||
* description = "Can be used to check API or server availability.",
|
|
||||||
* tags={"Server"},
|
|
||||||
* @OA\Response(response = "200", description = "OK"),
|
|
||||||
* @OA\Response(response = "401", description = "API key is missing or invalid."),
|
|
||||||
* security={
|
|
||||||
* {"Authorization":{"read"}}
|
|
||||||
* }
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* @OA\Tag(name = "Domains")
|
|
||||||
* @OA\Put(
|
|
||||||
* path="/domains/{name}",
|
|
||||||
* summary="Updates a domain.",
|
|
||||||
* description="Updates a domain. Only supplied fields will be updated, existing won't be affected.",
|
|
||||||
* tags={"Domains"},
|
|
||||||
* @OA\Response(response="200", description="OK"),
|
|
||||||
* @OA\Response(response = "401", description = "API key is missing or invalid."),
|
|
||||||
* @OA\Response(response="404", description="Domain not found."),
|
|
||||||
* security={
|
|
||||||
* {"Authorization":{"read":"write"}}
|
|
||||||
* }
|
|
||||||
* )
|
|
||||||
* @OA\Delete (
|
|
||||||
* path="/domains/{name}",
|
|
||||||
* summary="Deletes a domain.",
|
|
||||||
* description="Deletes a domain.",
|
|
||||||
* tags={"Domains"},
|
|
||||||
* @OA\Response(response="200", description="OK"),
|
|
||||||
* @OA\Response(response = "401", description = "API key is missing or invalid."),
|
|
||||||
* @OA\Response(response="404", description="Domain not found."),
|
|
||||||
* security={
|
|
||||||
* {"Authorization":{"read":"write"}}
|
|
||||||
* }
|
|
||||||
* )
|
|
||||||
* @param string $requestMethod
|
|
||||||
* @param array $uri
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
|
|
||||||
#[
|
|
||||||
OA\Get(
|
|
||||||
path: '/domains/{name}',
|
|
||||||
operationId: 'getSingleDomain',
|
|
||||||
description: 'Returns information of a single domain specified by its domain name.',
|
|
||||||
summary: 'Returns a single domain.',
|
|
||||||
security: [
|
|
||||||
['Authorization' => []]
|
|
||||||
],
|
|
||||||
tags: ['Domains'],
|
|
||||||
parameters: [
|
|
||||||
new OA\Parameter(name: 'name', in: 'path', required: true, schema: new OA\Schema(type: 'string')),
|
|
||||||
],
|
|
||||||
responses: [
|
|
||||||
new OA\Response(
|
|
||||||
response: 200,
|
|
||||||
description: 'OK'
|
|
||||||
),
|
|
||||||
new OA\Response(
|
|
||||||
response: 401,
|
|
||||||
description: 'API key is missing or invalid.'
|
|
||||||
),
|
|
||||||
new OA\Response(
|
|
||||||
response: 404,
|
|
||||||
description: 'Domain not found.'
|
|
||||||
)]
|
|
||||||
|
|
||||||
)]
|
|
||||||
private function validateApiKey(): bool
|
private function validateApiKey(): bool
|
||||||
{
|
{
|
||||||
$headers = array_change_key_case(array: getallheaders(), case: CASE_UPPER);
|
$headers = array_change_key_case(array: getallheaders(), case: CASE_UPPER);
|
||||||
|
@ -296,10 +222,33 @@ class RequestController
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[OA\Get(
|
||||||
|
path: '/domains/{name}',
|
||||||
|
operationId: 'getSingleDomain',
|
||||||
|
description: 'Returns information of a single domain specified by its domain name.',
|
||||||
|
summary: 'Returns a single domain.',
|
||||||
|
security: [
|
||||||
|
['Authorization' => []]
|
||||||
|
],
|
||||||
|
tags: ['Domains'],
|
||||||
|
parameters: [
|
||||||
|
new OA\Parameter(name: 'name', in: 'path', required: true, schema: new OA\Schema(type: 'string')),
|
||||||
|
],
|
||||||
|
responses: [
|
||||||
|
new OA\Response(
|
||||||
|
response: 200,
|
||||||
|
description: 'OK'
|
||||||
|
),
|
||||||
|
new OA\Response(
|
||||||
|
response: 401,
|
||||||
|
description: 'API key is missing or invalid.'
|
||||||
|
),
|
||||||
|
new OA\Response(
|
||||||
|
response: 404,
|
||||||
|
description: 'Domain not found.'
|
||||||
|
)]
|
||||||
|
|
||||||
/**
|
)]
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private function handleDomainsGetRequest(): void
|
private function handleDomainsGetRequest(): void
|
||||||
{
|
{
|
||||||
$name = $this->uri[3] ?? '';
|
$name = $this->uri[3] ?? '';
|
||||||
|
@ -620,7 +569,6 @@ class RequestController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function getDomain(string $host): string
|
private function getDomain(string $host): string
|
||||||
{
|
{
|
||||||
$host = strtolower(string: trim(string: $host));
|
$host = strtolower(string: trim(string: $host));
|
||||||
|
|
Loading…
Reference in New Issue