mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: add tld properties on API
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import ReactDOM from 'react-dom';
|
|
||||||
|
|
||||||
ReactDOM.render(<div></div>, document.getElementById('root'));
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace DoctrineMigrations;
|
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
|
||||||
use Doctrine\Migrations\AbstractMigration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Auto-generated Migration: Please modify to your needs!
|
|
||||||
*/
|
|
||||||
final class Version20240719164643 extends AbstractMigration
|
|
||||||
{
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this up() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('ALTER TABLE tld ADD COLUMN contract_terminated BOOLEAN DEFAULT NULL');
|
|
||||||
$this->addSql('ALTER TABLE tld ADD COLUMN date_of_contract_signature DATE DEFAULT NULL');
|
|
||||||
$this->addSql('ALTER TABLE tld ADD COLUMN delegation_date DATE DEFAULT NULL');
|
|
||||||
$this->addSql('ALTER TABLE tld ADD COLUMN registry_operator VARCHAR(255) DEFAULT NULL');
|
|
||||||
$this->addSql('ALTER TABLE tld ADD COLUMN removal_date DATE DEFAULT NULL');
|
|
||||||
$this->addSql('ALTER TABLE tld ADD COLUMN specification13 BOOLEAN DEFAULT NULL');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('CREATE TEMPORARY TABLE __temp__tld AS SELECT tld FROM tld');
|
|
||||||
$this->addSql('DROP TABLE tld');
|
|
||||||
$this->addSql('CREATE TABLE tld (tld VARCHAR(63) NOT NULL, PRIMARY KEY(tld))');
|
|
||||||
$this->addSql('INSERT INTO tld (tld) SELECT tld FROM __temp__tld');
|
|
||||||
$this->addSql('DROP TABLE __temp__tld');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
|
|||||||
/**
|
/**
|
||||||
* Auto-generated Migration: Please modify to your needs!
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
*/
|
*/
|
||||||
final class Version20240719124300 extends AbstractMigration
|
final class Version20240719183550 extends AbstractMigration
|
||||||
{
|
{
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
@@ -49,7 +49,10 @@ final class Version20240719124300 extends AbstractMigration
|
|||||||
$this->addSql('CREATE TABLE rdap_server (url VARCHAR(255) NOT NULL, tld_id VARCHAR(63) NOT NULL, updated_at DATE NOT NULL --(DC2Type:date_immutable)
|
$this->addSql('CREATE TABLE rdap_server (url VARCHAR(255) NOT NULL, tld_id VARCHAR(63) NOT NULL, updated_at DATE NOT NULL --(DC2Type:date_immutable)
|
||||||
, PRIMARY KEY(url, tld_id), CONSTRAINT FK_CCBF17A850F7084E FOREIGN KEY (tld_id) REFERENCES tld (tld) NOT DEFERRABLE INITIALLY IMMEDIATE)');
|
, PRIMARY KEY(url, tld_id), CONSTRAINT FK_CCBF17A850F7084E FOREIGN KEY (tld_id) REFERENCES tld (tld) NOT DEFERRABLE INITIALLY IMMEDIATE)');
|
||||||
$this->addSql('CREATE INDEX IDX_CCBF17A850F7084E ON rdap_server (tld_id)');
|
$this->addSql('CREATE INDEX IDX_CCBF17A850F7084E ON rdap_server (tld_id)');
|
||||||
$this->addSql('CREATE TABLE tld (tld VARCHAR(63) NOT NULL, PRIMARY KEY(tld))');
|
$this->addSql('CREATE TABLE tld (tld VARCHAR(63) NOT NULL, contract_terminated BOOLEAN DEFAULT NULL, date_of_contract_signature DATE DEFAULT NULL --(DC2Type:date_immutable)
|
||||||
|
, delegation_date DATE DEFAULT NULL --(DC2Type:date_immutable)
|
||||||
|
, registry_operator VARCHAR(255) DEFAULT NULL, removal_date DATE DEFAULT NULL --(DC2Type:date_immutable)
|
||||||
|
, specification13 BOOLEAN DEFAULT NULL, PRIMARY KEY(tld))');
|
||||||
$this->addSql('CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles CLOB NOT NULL --(DC2Type:json)
|
$this->addSql('CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles CLOB NOT NULL --(DC2Type:json)
|
||||||
, password VARCHAR(255) NOT NULL)');
|
, password VARCHAR(255) NOT NULL)');
|
||||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL ON user (email)');
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL ON user (email)');
|
||||||
@@ -2,18 +2,36 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
|
use ApiPlatform\Metadata\Get;
|
||||||
|
use ApiPlatform\Metadata\GetCollection;
|
||||||
use App\Repository\TldRepository;
|
use App\Repository\TldRepository;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\DBAL\Types\Types;
|
use Doctrine\DBAL\Types\Types;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Serializer\Attribute\Groups;
|
||||||
|
|
||||||
|
#[ApiResource(
|
||||||
|
shortName: 'Top Level Domain',
|
||||||
|
operations: [
|
||||||
|
new GetCollection(
|
||||||
|
uriTemplate: '/tld',
|
||||||
|
normalizationContext: ['groups' => ['tld:list']]
|
||||||
|
),
|
||||||
|
new Get(
|
||||||
|
uriTemplate: '/tld/{tld}',
|
||||||
|
normalizationContext: ['groups' => ['tld:item']]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)]
|
||||||
#[ORM\Entity(repositoryClass: TldRepository::class)]
|
#[ORM\Entity(repositoryClass: TldRepository::class)]
|
||||||
class Tld
|
class Tld
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\Column(length: 63)]
|
#[ORM\Column(length: 63)]
|
||||||
|
#[Groups(["tld:list", "tld:item"])]
|
||||||
private ?string $tld = null;
|
private ?string $tld = null;
|
||||||
/**
|
/**
|
||||||
* @var Collection<int, RdapServer>
|
* @var Collection<int, RdapServer>
|
||||||
@@ -22,21 +40,27 @@ class Tld
|
|||||||
private Collection $rdapServers;
|
private Collection $rdapServers;
|
||||||
|
|
||||||
#[ORM\Column(nullable: true)]
|
#[ORM\Column(nullable: true)]
|
||||||
|
#[Groups(["tld:list", "tld:item"])]
|
||||||
private ?bool $contractTerminated = null;
|
private ?bool $contractTerminated = null;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||||
|
#[Groups(["tld:item"])]
|
||||||
private ?DateTimeImmutable $dateOfContractSignature = null;
|
private ?DateTimeImmutable $dateOfContractSignature = null;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||||
|
#[Groups(["tld:item"])]
|
||||||
private ?DateTimeImmutable $delegationDate = null;
|
private ?DateTimeImmutable $delegationDate = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255, nullable: true)]
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
#[Groups(["tld:item"])]
|
||||||
private ?string $registryOperator = null;
|
private ?string $registryOperator = null;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||||
|
#[Groups(["tld:item"])]
|
||||||
private ?DateTimeImmutable $removalDate = null;
|
private ?DateTimeImmutable $removalDate = null;
|
||||||
|
|
||||||
#[ORM\Column(nullable: true)]
|
#[ORM\Column(nullable: true)]
|
||||||
|
#[Groups(["tld:item"])]
|
||||||
private ?bool $specification13 = null;
|
private ?bool $specification13 = null;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ use Throwable;
|
|||||||
#[AsMessageHandler]
|
#[AsMessageHandler]
|
||||||
final readonly class UpdateRdapServersHandler
|
final readonly class UpdateRdapServersHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct(private RDAPService $RDAPService)
|
public function __construct(private RDAPService $RDAPService)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -259,6 +259,7 @@ readonly class RDAPService
|
|||||||
foreach ($dnsRoot['services'] as $service) {
|
foreach ($dnsRoot['services'] as $service) {
|
||||||
|
|
||||||
foreach ($service[0] as $tld) {
|
foreach ($service[0] as $tld) {
|
||||||
|
if ($tld === "") continue;
|
||||||
$tldReference = $this->em->getReference(Tld::class, $tld);
|
$tldReference = $this->em->getReference(Tld::class, $tld);
|
||||||
foreach ($service[1] as $rdapServerUrl) {
|
foreach ($service[1] as $rdapServerUrl) {
|
||||||
$server = $this->rdapServerRepository->findOneBy(["tld" => $tldReference, "url" => $rdapServerUrl]); //ICI
|
$server = $this->rdapServerRepository->findOneBy(["tld" => $tldReference, "url" => $rdapServerUrl]); //ICI
|
||||||
@@ -293,6 +294,7 @@ readonly class RDAPService
|
|||||||
|
|
||||||
|
|
||||||
foreach (array_diff($tldList, $storedTldList) as $tld) {
|
foreach (array_diff($tldList, $storedTldList) as $tld) {
|
||||||
|
if ($tld === "") continue;
|
||||||
$this->em->persist((new Tld())->setTld($tld));
|
$this->em->persist((new Tld())->setTld($tld));
|
||||||
}
|
}
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
@@ -313,6 +315,7 @@ readonly class RDAPService
|
|||||||
)->toArray()['gTLDs'];
|
)->toArray()['gTLDs'];
|
||||||
|
|
||||||
foreach ($gTldList as $gTld) {
|
foreach ($gTldList as $gTld) {
|
||||||
|
if ($gTld['gTLD'] === "") continue;
|
||||||
$gtTldEntity = $this->tldRepository->findOneBy(['tld' => $gTld['gTLD']]);
|
$gtTldEntity = $this->tldRepository->findOneBy(['tld' => $gTld['gTLD']]);
|
||||||
if ($gtTldEntity === null) $gtTldEntity = new Tld();
|
if ($gtTldEntity === null) $gtTldEntity = new Tld();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user