Skip to content

Commit 4d3eb08

Browse files
committed
Merge branch 'main' of https://github.com/open-amt-cloud-toolkit/console into cira
2 parents a169c0c + a101ac7 commit 4d3eb08

File tree

20 files changed

+659
-587
lines changed

20 files changed

+659
-587
lines changed

.VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ jobs:
3535
- name: Check out code into the Go module directory
3636
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
3737
- name: golangci-lint
38-
uses: reviewdog/action-golangci-lint@dd3fda91790ca90e75049e5c767509dc0ec7d99b # v2.7.0
38+
uses: reviewdog/action-golangci-lint@3dfdce20f5ca12d264c214abb993dbb40834da90 # v2.7.2
3939
with:
4040
fail_level: error
41+
golangci_lint_version: v1.64.8 # pin golangci-lint version
4142
golangci_lint_flags: "--config=.github/.golangci.yml ./..."
4243

4344
yamllint:

.github/workflows/release.yml

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,46 @@ permissions:
1616

1717
jobs:
1818
prepare:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
version: ${{ steps.semantic-release.outputs.version }}
22+
steps:
23+
- name: Checkout Console
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
with:
26+
persist-credentials: false
27+
28+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
29+
with:
30+
go-version: ">=1.23.0"
31+
32+
- name: Install `@semantic-release/exec` plugin
33+
run: npm install @semantic-release/exec @semantic-release/changelog
34+
35+
- name: Semantic Release dry-run
36+
id: semantic-release
37+
env:
38+
GITHUB_REF: ${{ github.head_ref || github.ref_name }}
39+
GITHUB_TOKEN: ${{ secrets.ROSIE_TOKEN }}
40+
run: |
41+
# unset GITHUB_ACTIONS
42+
# git checkout -b ${{ github.base_ref }} pull/${{ github.event.number }}/merge
43+
npx semantic-release --dry-run --no-ci --branches main,$GITHUB_REF
44+
version=$(cat .VERSION)
45+
echo "version=$version" >> $GITHUB_OUTPUT
46+
47+
- name: Version
48+
run: echo "The next version is ${{ steps.semantic-release.outputs.version }}"
49+
50+
- name: Fail if version is empty
51+
run: |
52+
if [ -z "${{ steps.semantic-release.outputs.version }}" ]; then
53+
echo "Version output is empty. Failing the job."
54+
exit 1
55+
fi
56+
57+
build:
58+
needs: prepare
1959
strategy:
2060
matrix:
2161
os: [ubuntu-latest, macos-latest, windows-latest]
@@ -38,6 +78,11 @@ jobs:
3878
ref: main
3979
path: ./temp
4080

81+
- name: Use Node.js 22.x
82+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
83+
with:
84+
node-version: 22.x
85+
4186
- run: npm ci
4287
working-directory: ./temp
4388

@@ -50,34 +95,28 @@ jobs:
5095
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
5196
with:
5297
go-version: ">=1.23.0"
53-
- name: 🔬 Check semantic versioning
54-
id: semantic-release
55-
shell: bash
56-
env:
57-
GITHUB_REF: ${{ github.head_ref || github.ref_name }}
58-
GITHUB_TOKEN: ${{ secrets.ROSIE_TOKEN }}
59-
run: |
60-
npx semantic-release@21 --no-ci --dry-run --plugins @semantic-release/commit-analyzer --branches main
61-
VERSION=$(cat .VERSION)
62-
echo "VERSION=$VERSION" >> $GITHUB_ENV
98+
99+
- name: Version
100+
run: echo "The next version is ${{ needs.prepare.outputs.version }}"
101+
63102
- shell: bash
64103
run: |
65104
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
66105
#build linux
67106
- shell: bash
68107
if: matrix.os == 'ubuntu-latest'
69108
run: |
70-
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X 'github.com/open-amt-cloud-toolkit/console/internal/app.Version=$VERSION'" -trimpath -o dist/linux/console_linux_x64 ./cmd/app/main.go
109+
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X 'github.com/open-amt-cloud-toolkit/console/internal/app.Version=${{ needs.prepare.outputs.version }}'" -trimpath -o dist/linux/console_linux_x64 ./cmd/app/main.go
71110
72111
- shell: bash
73112
if: matrix.os == 'windows-latest'
74113
run: |
75-
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X 'github.com/open-amt-cloud-toolkit/console/internal/app.Version=$VERSION'" -trimpath -o dist/windows/console_windows_x64.exe ./cmd/app/main.go
114+
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X 'github.com/open-amt-cloud-toolkit/console/internal/app.Version=${{ needs.prepare.outputs.version }}'" -trimpath -o dist/windows/console_windows_x64.exe ./cmd/app/main.go
76115
77116
- shell: bash
78117
if: matrix.os == 'macos-latest'
79118
run: |
80-
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -X 'github.com/open-amt-cloud-toolkit/console/internal/app.Version=$VERSION'" -trimpath -o dist/darwin/console_mac_arm64 ./cmd/app/main.go
119+
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -X 'github.com/open-amt-cloud-toolkit/console/internal/app.Version=${{ needs.prepare.outputs.version }}'" -trimpath -o dist/darwin/console_mac_arm64 ./cmd/app/main.go
81120
82121
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
83122
if: matrix.os == 'ubuntu-latest'
@@ -102,7 +141,7 @@ jobs:
102141
permissions:
103142
contents: write # for Git to git push
104143
runs-on: ubuntu-latest
105-
needs: prepare
144+
needs: build
106145
steps:
107146
- name: Harden Runner
108147
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
@@ -113,48 +152,27 @@ jobs:
113152
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
114153
with:
115154
persist-credentials: false
116-
155+
117156
# copy the caches from prepare
118157
- shell: bash
119158
run: |
120159
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
160+
121161
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
122162
with:
123163
path: dist/linux
124164
key: linux-${{ env.sha_short }}
165+
125166
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
126167
with:
127168
path: dist/darwin
128169
key: darwin-${{ env.sha_short }}
170+
129171
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
130172
with:
131173
path: dist/windows
132174
key: windows-${{ env.sha_short }}
133175
enableCrossOsArchive: true
134-
- run: |
135-
ls -l dist
136-
ls -l
137-
138-
- name: Use Node.js 22.x
139-
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
140-
with:
141-
node-version: 22.x
142-
143-
- name: Check out Sample Web UI
144-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # master
145-
with:
146-
repository: open-amt-cloud-toolkit/sample-web-ui
147-
ref: main
148-
path: ./temp
149-
150-
- run: npm ci
151-
working-directory: ./temp
152-
153-
- run: npm run build-enterprise
154-
working-directory: ./temp
155-
156-
- name: move files
157-
run: mv ./temp/ui/* ./internal/controller/http/ui
158176

159177
- name: Docker Login
160178
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0

.releaserc.dryrun.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ require (
1212
github.com/gin-contrib/cors v1.7.4
1313
github.com/gin-gonic/gin v1.10.0
1414
github.com/go-xmlfmt/xmlfmt v1.1.3
15-
github.com/golang-jwt/jwt/v5 v5.2.1
15+
github.com/golang-jwt/jwt/v5 v5.2.2
1616
github.com/golang-migrate/migrate/v4 v4.18.2
1717
github.com/gorilla/websocket v1.5.3
1818
github.com/ilyakaznacheev/cleanenv v1.5.0
19-
github.com/jackc/pgx/v5 v5.7.2
20-
github.com/open-amt-cloud-toolkit/go-wsman-messages/v2 v2.21.0
19+
github.com/jackc/pgx/v5 v5.7.4
20+
github.com/open-amt-cloud-toolkit/go-wsman-messages/v2 v2.25.0
2121
github.com/prometheus/client_golang v1.21.1
22-
github.com/rs/zerolog v1.33.0
22+
github.com/rs/zerolog v1.34.0
2323
github.com/stretchr/testify v1.10.0
2424
github.com/swaggo/files v1.0.1
2525
github.com/swaggo/gin-swagger v1.6.0
2626
github.com/swaggo/swag v1.16.4
2727
go.uber.org/mock v0.5.0
2828
gopkg.in/yaml.v2 v2.4.0
29-
modernc.org/sqlite v1.36.1
29+
modernc.org/sqlite v1.36.2
3030
software.sslmate.com/src/go-pkcs12 v0.5.0
3131
)
3232

go.sum

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6
9191
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
9292
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
9393
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
94-
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
95-
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
94+
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
95+
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
9696
github.com/golang-migrate/migrate/v4 v4.18.2 h1:2VSCMz7x7mjyTXx3m2zPokOY82LTRgxK1yQYKo6wWQ8=
9797
github.com/golang-migrate/migrate/v4 v4.18.2/go.mod h1:2CM6tJvn2kqPXwnXO/d3rAQYiyoIm180VsO8PRX6Rpk=
9898
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
9999
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
100100
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
101-
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd h1:gbpYu9NMq8jhDVbvlGkMFWCjLFlqqEZjEmObmhUy6Vo=
102-
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
101+
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
102+
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
103103
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
104104
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
105105
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
@@ -117,8 +117,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
117117
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
118118
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
119119
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
120-
github.com/jackc/pgx/v5 v5.7.2 h1:mLoDLV6sonKlvjIEsV56SkWNCnuNv531l94GaIzO+XI=
121-
github.com/jackc/pgx/v5 v5.7.2/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ=
120+
github.com/jackc/pgx/v5 v5.7.4 h1:9wKznZrhWa2QiHL+NjTSPP6yjl3451BX3imWDnokYlg=
121+
github.com/jackc/pgx/v5 v5.7.4/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ=
122122
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
123123
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
124124
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
@@ -175,8 +175,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m
175175
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
176176
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
177177
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
178-
github.com/open-amt-cloud-toolkit/go-wsman-messages/v2 v2.21.0 h1:Bvp2JcdmpxkFZv2hfEHubK3x8CNQaSh6z6FfRM7G+6s=
179-
github.com/open-amt-cloud-toolkit/go-wsman-messages/v2 v2.21.0/go.mod h1:ezWfnNZ2up9X90aNy3B/5YpxCacyPB9dFANJc8UBuok=
178+
github.com/open-amt-cloud-toolkit/go-wsman-messages/v2 v2.25.0 h1:3d9yGzM8o4ghnaw4ucwHGG64lR1xvadJhtwgqaBD0z0=
179+
github.com/open-amt-cloud-toolkit/go-wsman-messages/v2 v2.25.0/go.mod h1:ezWfnNZ2up9X90aNy3B/5YpxCacyPB9dFANJc8UBuok=
180180
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
181181
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
182182
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
@@ -199,9 +199,9 @@ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94
199199
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
200200
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
201201
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
202-
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
203-
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
204-
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
202+
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
203+
github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
204+
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
205205
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
206206
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
207207
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -321,8 +321,8 @@ modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
321321
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
322322
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
323323
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
324-
modernc.org/sqlite v1.36.1 h1:bDa8BJUH4lg6EGkLbahKe/8QqoF8p9gArSc6fTqYhyQ=
325-
modernc.org/sqlite v1.36.1/go.mod h1:7MPwH7Z6bREicF9ZVUR78P1IKuxfZ8mRIDHD0iD+8TU=
324+
modernc.org/sqlite v1.36.2 h1:vjcSazuoFve9Wm0IVNHgmJECoOXLZM1KfMXbcX2axHA=
325+
modernc.org/sqlite v1.36.2/go.mod h1:ADySlx7K4FdY5MaJcEv86hTJ0PjedAloTUuif0YS3ws=
326326
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
327327
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
328328
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=

internal/app/migrate.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import (
1717
"github.com/golang-migrate/migrate/v4/source"
1818
_ "github.com/golang-migrate/migrate/v4/source/file" // for file source
1919
"github.com/golang-migrate/migrate/v4/source/iofs"
20-
"github.com/open-amt-cloud-toolkit/console/config"
2120
_ "modernc.org/sqlite" // sqlite3 driver
21+
22+
"github.com/open-amt-cloud-toolkit/console/config"
2223
)
2324

2425
const (

internal/controller/http/router.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var content embed.FS
2929
// @version 1.0
3030
// @host localhost:8181
3131
// @BasePath /v1
32-
func NewRouter(handler *gin.Engine, l logger.Interface, t usecase.Usecases, cfg *config.Config) {
32+
func NewRouter(handler *gin.Engine, l logger.Interface, t usecase.Usecases, cfg *config.Config) { //nolint:funlen // This function is responsible for setting up the router, so it's expected to be long
3333
// Options
3434
handler.Use(gin.Logger())
3535
handler.Use(gin.Recovery())
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package v1
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/gin-gonic/gin"
7+
8+
"github.com/open-amt-cloud-toolkit/console/internal/entity/dto/v1"
9+
)
10+
11+
func (r *deviceManagementRoutes) getAlarmOccurrences(c *gin.Context) {
12+
guid := c.Param("guid")
13+
14+
alarms, err := r.d.GetAlarmOccurrences(c.Request.Context(), guid)
15+
if err != nil {
16+
r.l.Error(err, "http - v1 - getFeatures")
17+
ErrorResponse(c, err)
18+
19+
return
20+
}
21+
22+
c.JSON(http.StatusOK, alarms)
23+
}
24+
25+
func (r *deviceManagementRoutes) createAlarmOccurrences(c *gin.Context) {
26+
guid := c.Param("guid")
27+
28+
alarm := &dto.AlarmClockOccurrenceInput{}
29+
if err := c.ShouldBindJSON(alarm); err != nil {
30+
ErrorResponse(c, err)
31+
32+
return
33+
}
34+
35+
alarmReference, err := r.d.CreateAlarmOccurrences(c.Request.Context(), guid, *alarm)
36+
if err != nil {
37+
r.l.Error(err, "http - v1 - createAlarmOccurrences")
38+
ErrorResponse(c, err)
39+
40+
return
41+
}
42+
43+
c.JSON(http.StatusCreated, alarmReference)
44+
}
45+
46+
func (r *deviceManagementRoutes) deleteAlarmOccurrences(c *gin.Context) {
47+
guid := c.Param("guid")
48+
49+
alarm := dto.DeleteAlarmOccurrenceRequest{}
50+
if err := c.ShouldBindJSON(&alarm); err != nil {
51+
ErrorResponse(c, err)
52+
53+
return
54+
}
55+
56+
err := r.d.DeleteAlarmOccurrences(c.Request.Context(), guid, alarm.Name)
57+
if err != nil {
58+
r.l.Error(err, "http - v1 - deleteAlarmOccurrences")
59+
ErrorResponse(c, err)
60+
61+
return
62+
}
63+
64+
c.JSON(http.StatusNoContent, nil)
65+
}

0 commit comments

Comments
 (0)