Documentation ¶
Index ¶
- func NewDB(driverName string, dataSourceName string, logger log.Logger) (store.DB, error)
- type DB
- func (db *DB) DeleteDevice(ctx context.Context, id string) error
- func (db *DB) InsertDevice(ctx context.Context, alias string, deviceID string, dmsID string, ...) error
- func (db *DB) InsertDeviceCertHistory(ctx context.Context, certHistory device.DeviceCertHistory) error
- func (db *DB) InsertLog(ctx context.Context, logDev device.DeviceLog) error
- func (db *DB) SelectAllDevices(ctx context.Context, queryParameters device.QueryParameters) ([]device.Device, int, error)
- func (db *DB) SelectAllDevicesByDmsId(ctx context.Context, dms_id string) ([]device.Device, error)
- func (db *DB) SelectDeviceById(ctx context.Context, id string) (device.Device, error)
- func (db *DB) SelectDeviceCertHistory(ctx context.Context, deviceId string) ([]device.DeviceCertHistory, error)
- func (db *DB) SelectDeviceCertHistoryBySerialNumber(ctx context.Context, serialNumber string) (device.DeviceCertHistory, error)
- func (db *DB) SelectDeviceCertHistoryLastThirtyDays(ctx context.Context, queryParameters device.QueryParameters) ([]device.DeviceCertHistory, error)
- func (db *DB) SelectDeviceLogs(ctx context.Context, deviceId string) ([]device.DeviceLog, error)
- func (db *DB) SelectDmssLastIssuedCert(ctx context.Context, queryParameters device.QueryParameters) ([]device.DMSLastIssued, error)
- func (db *DB) UpdateByID(ctx context.Context, alias string, deviceID string, dmsID string, ...) error
- func (db *DB) UpdateDeviceCertificateSerialNumberByID(ctx context.Context, id string, serialNumber string) error
- func (db *DB) UpdateDeviceStatusByID(ctx context.Context, id string, newStatus string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
func (*DB) InsertDevice ¶
func (*DB) InsertDeviceCertHistory ¶
func (*DB) SelectAllDevices ¶
func (*DB) SelectAllDevicesByDmsId ¶
func (*DB) SelectDeviceById ¶
func (*DB) SelectDeviceCertHistory ¶
func (*DB) SelectDeviceCertHistoryBySerialNumber ¶
func (*DB) SelectDeviceCertHistoryLastThirtyDays ¶
func (db *DB) SelectDeviceCertHistoryLastThirtyDays(ctx context.Context, queryParameters device.QueryParameters) ([]device.DeviceCertHistory, error)
func (*DB) SelectDeviceLogs ¶
func (*DB) SelectDmssLastIssuedCert ¶
func (db *DB) SelectDmssLastIssuedCert(ctx context.Context, queryParameters device.QueryParameters) ([]device.DMSLastIssued, error)
func (db *DB) UpdateDeviceCertHistory(ctx context.Context, deviceId string, serialNumber string, newStatus string) error { db.logger = ctx.Value(utils.LamassuLoggerContextKey).(log.Logger) parentSpan := opentracing.SpanFromContext(ctx) sqlStatement := ` UPDATE device_certificates_history SET status = $2, revocation_ts = $3 WHERE serial_number = $1 ` span := opentracing.StartSpan("lamassu-device-manager: updated Devices Cert History with ID "+serialNumber+" to "+newStatus+" status", opentracing.ChildOf(parentSpan.Context())) res, err := db.Exec(sqlStatement, serialNumber, newStatus, time.Now()) span.Finish() if err != nil { level.Debug(db.logger).Log("err", err, "msg", "Could not updated Devices Cert History with ID "+serialNumber+" to "+newStatus+" status") return err } count, err := res.RowsAffected() if err != nil { return err } if count <= 0 { err = errors.New("no rows have been updated in database") level.Debug(db.logger).Log("err", err) return err } level.Debug(db.logger).Log("err", err, "msg", "Updated Devices Cert History with ID "+serialNumber+" to "+newStatus+" status") return nil }
func (*DB) UpdateByID ¶ added in v0.0.10
func (*DB) UpdateDeviceCertificateSerialNumberByID ¶
Click to show internal directories.
Click to hide internal directories.