2024-08-08 16:13:30 +07:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/tigorlazuardi/bluemage/go/gen/models"
|
|
|
|
"github.com/tigorlazuardi/bluemage/go/pkg/errs"
|
|
|
|
"github.com/tigorlazuardi/bluemage/go/pkg/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (api *API) DevicesExist(ctx context.Context, slug string) (exists bool, err error) {
|
|
|
|
ctx, coll := log.WithQueryCollector(ctx)
|
2024-08-13 09:40:02 +07:00
|
|
|
exists, err = models.DeviceExists(ctx, api.Executor, slug)
|
2024-08-08 16:13:30 +07:00
|
|
|
if err != nil {
|
|
|
|
return exists, errs.Wrapw(err, "failed to check device existence",
|
|
|
|
"slug", slug,
|
|
|
|
"query", coll,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
return exists, nil
|
|
|
|
}
|