mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-18 02:05:36 +00:00
feat: update API endpoints
This commit is contained in:
parent
36a76f2876
commit
c9b9cdad59
@ -4,6 +4,7 @@ namespace App\Entity;
|
|||||||
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
use ApiPlatform\Metadata\Get;
|
use ApiPlatform\Metadata\Get;
|
||||||
|
use ApiPlatform\Metadata\GetCollection;
|
||||||
use App\Repository\DomainRepository;
|
use App\Repository\DomainRepository;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
@ -16,16 +17,26 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
|||||||
#[UniqueEntity('handle')]
|
#[UniqueEntity('handle')]
|
||||||
#[ApiResource(
|
#[ApiResource(
|
||||||
operations: [
|
operations: [
|
||||||
|
new GetCollection(
|
||||||
|
uriTemplate: '/domains',
|
||||||
|
normalizationContext: [
|
||||||
|
'groups' => [
|
||||||
|
'domain:list'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
),
|
||||||
new Get(
|
new Get(
|
||||||
uriTemplate: '/domains/{ldhName}',
|
uriTemplate: '/domains/{ldhName}',
|
||||||
normalizationContext: ['groups' => [
|
normalizationContext: [
|
||||||
'domain:item',
|
'groups' => [
|
||||||
'event:list',
|
'domain:item',
|
||||||
'entity:list',
|
'event:list',
|
||||||
'domain-entity:entity',
|
'entity:list',
|
||||||
'nameserver-entity:nameserver',
|
'domain-entity:entity',
|
||||||
'nameserver:item',
|
'nameserver-entity:nameserver',
|
||||||
]]
|
'nameserver:item',
|
||||||
|
]
|
||||||
|
]
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
)]
|
)]
|
||||||
@ -33,11 +44,11 @@ class Domain
|
|||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
#[Groups(['domain:item'])]
|
#[Groups(['domain:item', 'domain:list'])]
|
||||||
private ?string $ldhName = null;
|
private ?string $ldhName = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
#[Groups(['domain:item'])]
|
#[Groups(['domain:item', 'domain:list'])]
|
||||||
private ?string $handle = null;
|
private ?string $handle = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2,22 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
|
||||||
use ApiPlatform\Metadata\Get;
|
|
||||||
use App\Repository\DomainEventRepository;
|
use App\Repository\DomainEventRepository;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: DomainEventRepository::class)]
|
#[ORM\Entity(repositoryClass: DomainEventRepository::class)]
|
||||||
#[ApiResource(
|
|
||||||
operations: [
|
|
||||||
new Get(
|
|
||||||
uriTemplate: '/events/domain/{id}',
|
|
||||||
shortName: 'Domain Event',
|
|
||||||
class: DomainEvent::class,
|
|
||||||
normalizationContext: ['groups' => ['event:list']]
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)]
|
|
||||||
class DomainEvent extends Event
|
class DomainEvent extends Event
|
||||||
{
|
{
|
||||||
#[ORM\ManyToOne(targetEntity: Domain::class, cascade: ['persist'], inversedBy: 'events')]
|
#[ORM\ManyToOne(targetEntity: Domain::class, cascade: ['persist'], inversedBy: 'events')]
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
||||||
|
use ApiPlatform\Metadata\ApiFilter;
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
use ApiPlatform\Metadata\Get;
|
use ApiPlatform\Metadata\Get;
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
use ApiPlatform\Metadata\GetCollection;
|
||||||
@ -12,6 +14,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
use Symfony\Component\Serializer\Attribute\Groups;
|
use Symfony\Component\Serializer\Attribute\Groups;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: EntityRepository::class)]
|
#[ORM\Entity(repositoryClass: EntityRepository::class)]
|
||||||
|
#[ApiFilter(SearchFilter::class, properties: ['jCard' => 'partial'])]
|
||||||
#[ApiResource(
|
#[ApiResource(
|
||||||
operations: [
|
operations: [
|
||||||
new GetCollection(
|
new GetCollection(
|
||||||
@ -58,7 +61,7 @@ class Entity
|
|||||||
* @var Collection<int, EntityEvent>
|
* @var Collection<int, EntityEvent>
|
||||||
*/
|
*/
|
||||||
#[ORM\OneToMany(targetEntity: EntityEvent::class, mappedBy: 'entity', cascade: ['persist'], orphanRemoval: true)]
|
#[ORM\OneToMany(targetEntity: EntityEvent::class, mappedBy: 'entity', cascade: ['persist'], orphanRemoval: true)]
|
||||||
#[Groups(['entity:list', 'entity:item'])]
|
#[Groups(['entity:list', 'entity:item', 'entity:list'])]
|
||||||
private Collection $events;
|
private Collection $events;
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
|
|||||||
@ -2,24 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
|
||||||
use ApiPlatform\Metadata\Get;
|
|
||||||
use App\Repository\EntityEventRepository;
|
use App\Repository\EntityEventRepository;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: EntityEventRepository::class)]
|
#[ORM\Entity(repositoryClass: EntityEventRepository::class)]
|
||||||
#[ApiResource(
|
|
||||||
operations: [
|
|
||||||
new Get(
|
|
||||||
uriTemplate: '/events/entity/{id}',
|
|
||||||
shortName: 'Entity Event',
|
|
||||||
class: EntityEvent::class,
|
|
||||||
normalizationContext: [
|
|
||||||
'groups' => ['event:list']
|
|
||||||
]
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)]
|
|
||||||
class EntityEvent extends Event
|
class EntityEvent extends Event
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
|
||||||
use ApiPlatform\Metadata\Get;
|
|
||||||
use App\Config\EventAction;
|
use App\Config\EventAction;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|||||||
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
|
||||||
use ApiPlatform\Metadata\Get;
|
|
||||||
use App\Repository\NameserverRepository;
|
use App\Repository\NameserverRepository;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
@ -11,20 +9,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
use Symfony\Component\Serializer\Attribute\Groups;
|
use Symfony\Component\Serializer\Attribute\Groups;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: NameserverRepository::class)]
|
#[ORM\Entity(repositoryClass: NameserverRepository::class)]
|
||||||
#[ApiResource(
|
|
||||||
operations: [
|
|
||||||
new Get(
|
|
||||||
uriTemplate: '/nameservers/{ldhName}',
|
|
||||||
normalizationContext: [
|
|
||||||
'groups' => [
|
|
||||||
'nameserver:item',
|
|
||||||
'entity:list',
|
|
||||||
'nameserver-entity:entity'
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)]
|
|
||||||
class Nameserver
|
class Nameserver
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -37,7 +21,6 @@ class Nameserver
|
|||||||
* @var Collection<int, NameserverEntity>
|
* @var Collection<int, NameserverEntity>
|
||||||
*/
|
*/
|
||||||
#[ORM\OneToMany(targetEntity: NameserverEntity::class, mappedBy: 'nameserver', cascade: ['persist'], orphanRemoval: true)]
|
#[ORM\OneToMany(targetEntity: NameserverEntity::class, mappedBy: 'nameserver', cascade: ['persist'], orphanRemoval: true)]
|
||||||
#[Groups(['nameserver:item'])]
|
|
||||||
private Collection $nameserverEntities;
|
private Collection $nameserverEntities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user