Skip to content

Commit 7bc2413

Browse files
heiytorgustavosbarreto
authored andcommitted
refactor(api): restructure tags system with dedicated collection
- Remove device and public key tag operations from individual services - Create centralized tag management with dedicated tags collection - Replace inline tag arrays with reference-based tagging system - Add new tag endpoints for CRUD operations and target association - Update device and public key models to use Taggable embedding - Migrate existing tags to new collection structure - Remove deprecated tag-related routes and handlers - Update fixtures and tests for new tag architecture
1 parent 10a539f commit 7bc2413

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3737
-4337
lines changed

api/routes/device.go

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,12 @@ const (
1919
OfflineDeviceURL = "/devices/:uid/offline"
2020
LookupDeviceURL = "/device/lookup"
2121
UpdateDeviceStatusURL = "/devices/:uid/:status"
22-
CreateTagURL = "/devices/:uid/tags" // Add a tag to a device.
23-
UpdateTagURL = "/devices/:uid/tags" // Update device's tags with a new set.
24-
RemoveTagURL = "/devices/:uid/tags/:tag" // Delete a tag from a device.
2522
UpdateDevice = "/devices/:uid"
2623
)
2724

2825
const (
2926
ParamDeviceID = "uid"
3027
ParamDeviceStatus = "status"
31-
ParamTagName = "name"
3228
)
3329

3430
func (h *Handler) GetDeviceList(c gateway.Context) error {
@@ -244,57 +240,6 @@ func (h *Handler) UpdateDeviceStatus(c gateway.Context) error {
244240
return c.NoContent(http.StatusOK)
245241
}
246242

247-
func (h *Handler) CreateDeviceTag(c gateway.Context) error {
248-
var req requests.DeviceCreateTag
249-
if err := c.Bind(&req); err != nil {
250-
return err
251-
}
252-
253-
if err := c.Validate(&req); err != nil {
254-
return err
255-
}
256-
257-
if err := h.service.CreateDeviceTag(c.Ctx(), models.UID(req.UID), req.Tag); err != nil {
258-
return err
259-
}
260-
261-
return c.NoContent(http.StatusOK)
262-
}
263-
264-
func (h *Handler) RemoveDeviceTag(c gateway.Context) error {
265-
var req requests.DeviceRemoveTag
266-
if err := c.Bind(&req); err != nil {
267-
return err
268-
}
269-
270-
if err := c.Validate(&req); err != nil {
271-
return err
272-
}
273-
274-
if err := h.service.RemoveDeviceTag(c.Ctx(), models.UID(req.UID), req.Tag); err != nil {
275-
return err
276-
}
277-
278-
return c.NoContent(http.StatusOK)
279-
}
280-
281-
func (h *Handler) UpdateDeviceTag(c gateway.Context) error {
282-
var req requests.DeviceUpdateTag
283-
if err := c.Bind(&req); err != nil {
284-
return err
285-
}
286-
287-
if err := c.Validate(&req); err != nil {
288-
return err
289-
}
290-
291-
if err := h.service.UpdateDeviceTag(c.Ctx(), models.UID(req.UID), req.Tags); err != nil {
292-
return err
293-
}
294-
295-
return c.NoContent(http.StatusOK)
296-
}
297-
298243
func (h *Handler) UpdateDevice(c gateway.Context) error {
299244
req := new(requests.DeviceUpdate)
300245

0 commit comments

Comments
 (0)