From e2d92499bc28fb2d8013e9ae5904bc13d87ae7d3 Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Wed, 8 Mar 2023 16:15:21 +0100 Subject: [PATCH] Host deregistration events (#1245) * Host deregistration commands * Host deregistration events * Fixing module attributes in host deregistration commands --- lib/trento/domain/host/commands/deregister_host.ex | 12 ++++++++++++ .../host/commands/request_host_deregistration.ex | 12 ++++++++++++ lib/trento/domain/host/events/host_deregistered.ex | 12 ++++++++++++ .../host/events/host_deregistration_requested.ex | 11 +++++++++++ 4 files changed, 47 insertions(+) create mode 100644 lib/trento/domain/host/commands/deregister_host.ex create mode 100644 lib/trento/domain/host/commands/request_host_deregistration.ex create mode 100644 lib/trento/domain/host/events/host_deregistered.ex create mode 100644 lib/trento/domain/host/events/host_deregistration_requested.ex diff --git a/lib/trento/domain/host/commands/deregister_host.ex b/lib/trento/domain/host/commands/deregister_host.ex new file mode 100644 index 0000000000..94839974c3 --- /dev/null +++ b/lib/trento/domain/host/commands/deregister_host.ex @@ -0,0 +1,12 @@ +defmodule Trento.Domain.Host.Commands.DeregisterHost do + @moduledoc """ + Deregister a host + """ + @required_fields :all + + use Trento.Command + + defcommand do + field :host_id, Ecto.UUID + end +end diff --git a/lib/trento/domain/host/commands/request_host_deregistration.ex b/lib/trento/domain/host/commands/request_host_deregistration.ex new file mode 100644 index 0000000000..fcd2831460 --- /dev/null +++ b/lib/trento/domain/host/commands/request_host_deregistration.ex @@ -0,0 +1,12 @@ +defmodule Trento.Domain.Host.Commands.RequestHostDeregistration do + @moduledoc """ + Request a deregistration of a host + """ + @required_fields :all + + use Trento.Command + + defcommand do + field :host_id, Ecto.UUID + end +end diff --git a/lib/trento/domain/host/events/host_deregistered.ex b/lib/trento/domain/host/events/host_deregistered.ex new file mode 100644 index 0000000000..6b81d4ecc2 --- /dev/null +++ b/lib/trento/domain/host/events/host_deregistered.ex @@ -0,0 +1,12 @@ +defmodule Trento.Domain.Host.Events.HostDeregistered do + @moduledoc """ + This event is emitted when a deregistration (decomission) of a host is completed. + """ + + use Trento.Event + + defevent do + field :host_id, Ecto.UUID + field :deregistered_at, :utc_datetime_usec + end +end diff --git a/lib/trento/domain/host/events/host_deregistration_requested.ex b/lib/trento/domain/host/events/host_deregistration_requested.ex new file mode 100644 index 0000000000..214639cad8 --- /dev/null +++ b/lib/trento/domain/host/events/host_deregistration_requested.ex @@ -0,0 +1,11 @@ +defmodule Trento.Domain.Host.Events.HostDeregistrationRequested do + @moduledoc """ + This event is emitted when a deregistration (decomission) of a host is requested. + """ + + use Trento.Event + + defevent do + field :host_id, Ecto.UUID + end +end