Skip to content

Commit 7f1de2d

Browse files
committed
feat(data access): add ownership voucher schema
Signed-off-by: Eddy Babetto <eddy.babetto@secomind.com>
1 parent 55837a2 commit 7f1de2d

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# This file is part of Astarte.
3+
#
4+
# Copyright 2025 SECO Mind Srl
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
defmodule Astarte.DataAccess.FDO.OwnershipVoucher do
20+
use Ecto.Schema
21+
import Ecto.Changeset
22+
alias Astarte.DataAccess.FDO.OwnershipVoucher
23+
use TypedEctoSchema
24+
25+
@primary_key {:id, Ecto.UUID, autogenerate: true}
26+
typed_schema "ownership_vouchers" do
27+
field :private_key, :binary
28+
field :voucher_data, :binary
29+
field :expiry, :integer
30+
end
31+
32+
@doc false
33+
def changeset(%OwnershipVoucher{} = ownership_voucher, attrs) do
34+
ownership_voucher
35+
|> cast(attrs, [:private_key, :voucher_data, :expiry])
36+
|> validate_required([:private_key, :voucher_data, :expiry])
37+
end
38+
end

0 commit comments

Comments
 (0)