• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / reporting / 1571619767

13 Sep 2024 10:52AM UTC coverage: 85.292% (+0.06%) from 85.235%
1571619767

push

gitlab-ci

web-flow
Merge pull request #202 from mzedel/chore/deprecate

Chore/deprecate

2998 of 3515 relevant lines covered (85.29%)

14.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/api/http/internal_devices.go
1
// Copyright 2022 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15
package http
16

17
import (
18
        "net/http"
19
        "strconv"
20

21
        "github.com/gin-gonic/gin"
22
        "github.com/pkg/errors"
23

24
        "github.com/mendersoftware/go-lib-micro/identity"
25
        "github.com/mendersoftware/go-lib-micro/rest.utils"
26
)
27

28
func (mc *InternalController) SearchDevices(c *gin.Context) {
12✔
29
        tid := c.Param("tenant_id")
12✔
30

12✔
31
        ctx := c.Request.Context()
12✔
32
        ctx = identity.WithContext(ctx, &identity.Identity{Tenant: tid})
12✔
33

12✔
34
        params, err := parseSearchDevicesParams(ctx, c)
12✔
35

12✔
36
        if err != nil {
13✔
37
                rest.RenderError(c,
1✔
38
                        http.StatusBadRequest,
1✔
39
                        errors.Wrap(err, "malformed request body"),
1✔
40
                )
1✔
41
                return
1✔
42
        }
1✔
43

44
        res, total, err := mc.reporting.SearchDevices(ctx, params)
11✔
45
        if err != nil {
12✔
46
                rest.RenderError(c,
1✔
47
                        http.StatusInternalServerError,
1✔
48
                        err,
1✔
49
                )
1✔
50
                return
1✔
51
        }
1✔
52

53
        pageLinkHdrs(c, params.Page, params.PerPage, total)
10✔
54

10✔
55
        c.Header(hdrTotalCount, strconv.Itoa(total))
10✔
56
        c.JSON(http.StatusOK, res)
10✔
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc