You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

302 lines
6.9 KiB

2 years ago
2 years ago
  1. // Code generated by sqlc. DO NOT EDIT.
  2. // versions:
  3. // sqlc v1.13.0
  4. // source: device.sql
  5. package mysqlgen
  6. import (
  7. "context"
  8. "encoding/json"
  9. "time"
  10. "github.com/google/uuid"
  11. )
  12. const deleteDeviceAlias = `-- name: DeleteDeviceAlias :exec
  13. DELETE
  14. FROM device_alias
  15. WHERE id = ?
  16. AND alias = ?
  17. `
  18. type DeleteDeviceAliasParams struct {
  19. ID string
  20. Alias string
  21. }
  22. func (q *Queries) DeleteDeviceAlias(ctx context.Context, arg DeleteDeviceAliasParams) error {
  23. _, err := q.exec(ctx, q.deleteDeviceAliasStmt, deleteDeviceAlias, arg.ID, arg.Alias)
  24. return err
  25. }
  26. const deleteDeviceAliasByID = `-- name: DeleteDeviceAliasByID :exec
  27. DELETE
  28. FROM device_alias
  29. WHERE id = ?
  30. `
  31. func (q *Queries) DeleteDeviceAliasByID(ctx context.Context, id string) error {
  32. _, err := q.exec(ctx, q.deleteDeviceAliasByIDStmt, deleteDeviceAliasByID, id)
  33. return err
  34. }
  35. const deleteDeviceAliasByIDLike = `-- name: DeleteDeviceAliasByIDLike :exec
  36. DELETE
  37. FROM device_alias
  38. WHERE id LIKE ?
  39. `
  40. func (q *Queries) DeleteDeviceAliasByIDLike(ctx context.Context, id string) error {
  41. _, err := q.exec(ctx, q.deleteDeviceAliasByIDLikeStmt, deleteDeviceAliasByIDLike, id)
  42. return err
  43. }
  44. const deleteDeviceAssignment = `-- name: DeleteDeviceAssignment :exec
  45. DELETE
  46. FROM device_assignment
  47. WHERE id = ?
  48. `
  49. func (q *Queries) DeleteDeviceAssignment(ctx context.Context, id uuid.UUID) error {
  50. _, err := q.exec(ctx, q.deleteDeviceAssignmentStmt, deleteDeviceAssignment, id)
  51. return err
  52. }
  53. const deleteDeviceAuth = `-- name: DeleteDeviceAuth :exec
  54. DELETE
  55. FROM device_auth
  56. WHERE id = ?
  57. `
  58. func (q *Queries) DeleteDeviceAuth(ctx context.Context, id string) error {
  59. _, err := q.exec(ctx, q.deleteDeviceAuthStmt, deleteDeviceAuth, id)
  60. return err
  61. }
  62. const deleteDeviceInfo = `-- name: DeleteDeviceInfo :exec
  63. DELETE
  64. FROM device_info
  65. WHERE id = ?
  66. AND kind = ?
  67. `
  68. type DeleteDeviceInfoParams struct {
  69. ID string
  70. Kind string
  71. }
  72. func (q *Queries) DeleteDeviceInfo(ctx context.Context, arg DeleteDeviceInfoParams) error {
  73. _, err := q.exec(ctx, q.deleteDeviceInfoStmt, deleteDeviceInfo, arg.ID, arg.Kind)
  74. return err
  75. }
  76. const deleteDeviceInfoByID = `-- name: DeleteDeviceInfoByID :exec
  77. DELETE
  78. FROM device_info
  79. WHERE id = ?
  80. `
  81. func (q *Queries) DeleteDeviceInfoByID(ctx context.Context, id string) error {
  82. _, err := q.exec(ctx, q.deleteDeviceInfoByIDStmt, deleteDeviceInfoByID, id)
  83. return err
  84. }
  85. const deleteDeviceInfoLike = `-- name: DeleteDeviceInfoLike :exec
  86. DELETE
  87. FROM device_info
  88. WHERE id LIKE ?
  89. `
  90. func (q *Queries) DeleteDeviceInfoLike(ctx context.Context, id string) error {
  91. _, err := q.exec(ctx, q.deleteDeviceInfoLikeStmt, deleteDeviceInfoLike, id)
  92. return err
  93. }
  94. const insertDeviceAlias = `-- name: InsertDeviceAlias :exec
  95. INSERT INTO device_alias (id, alias)
  96. VALUES (?, ?)
  97. ON DUPLICATE KEY UPDATE alias=alias
  98. `
  99. type InsertDeviceAliasParams struct {
  100. ID string
  101. Alias string
  102. }
  103. func (q *Queries) InsertDeviceAlias(ctx context.Context, arg InsertDeviceAliasParams) error {
  104. _, err := q.exec(ctx, q.insertDeviceAliasStmt, insertDeviceAlias, arg.ID, arg.Alias)
  105. return err
  106. }
  107. const listDeviceAliases = `-- name: ListDeviceAliases :many
  108. SELECT id, alias
  109. FROM device_alias
  110. `
  111. func (q *Queries) ListDeviceAliases(ctx context.Context) ([]DeviceAlias, error) {
  112. rows, err := q.query(ctx, q.listDeviceAliasesStmt, listDeviceAliases)
  113. if err != nil {
  114. return nil, err
  115. }
  116. defer rows.Close()
  117. items := []DeviceAlias{}
  118. for rows.Next() {
  119. var i DeviceAlias
  120. if err := rows.Scan(&i.ID, &i.Alias); err != nil {
  121. return nil, err
  122. }
  123. items = append(items, i)
  124. }
  125. if err := rows.Close(); err != nil {
  126. return nil, err
  127. }
  128. if err := rows.Err(); err != nil {
  129. return nil, err
  130. }
  131. return items, nil
  132. }
  133. const listDeviceAssignments = `-- name: ListDeviceAssignments :many
  134. SELECT id, created_date, ` + "`" + `match` + "`" + `, effect
  135. FROM device_assignment
  136. ORDER BY created_date
  137. `
  138. func (q *Queries) ListDeviceAssignments(ctx context.Context) ([]DeviceAssignment, error) {
  139. rows, err := q.query(ctx, q.listDeviceAssignmentsStmt, listDeviceAssignments)
  140. if err != nil {
  141. return nil, err
  142. }
  143. defer rows.Close()
  144. items := []DeviceAssignment{}
  145. for rows.Next() {
  146. var i DeviceAssignment
  147. if err := rows.Scan(
  148. &i.ID,
  149. &i.CreatedDate,
  150. &i.Match,
  151. &i.Effect,
  152. ); err != nil {
  153. return nil, err
  154. }
  155. items = append(items, i)
  156. }
  157. if err := rows.Close(); err != nil {
  158. return nil, err
  159. }
  160. if err := rows.Err(); err != nil {
  161. return nil, err
  162. }
  163. return items, nil
  164. }
  165. const listDeviceAuth = `-- name: ListDeviceAuth :many
  166. SELECT id, api_key, extras
  167. FROM device_auth
  168. `
  169. func (q *Queries) ListDeviceAuth(ctx context.Context) ([]DeviceAuth, error) {
  170. rows, err := q.query(ctx, q.listDeviceAuthStmt, listDeviceAuth)
  171. if err != nil {
  172. return nil, err
  173. }
  174. defer rows.Close()
  175. items := []DeviceAuth{}
  176. for rows.Next() {
  177. var i DeviceAuth
  178. if err := rows.Scan(&i.ID, &i.ApiKey, &i.Extras); err != nil {
  179. return nil, err
  180. }
  181. items = append(items, i)
  182. }
  183. if err := rows.Close(); err != nil {
  184. return nil, err
  185. }
  186. if err := rows.Err(); err != nil {
  187. return nil, err
  188. }
  189. return items, nil
  190. }
  191. const listDeviceInfos = `-- name: ListDeviceInfos :many
  192. SELECT id, kind, data
  193. FROM device_info
  194. `
  195. func (q *Queries) ListDeviceInfos(ctx context.Context) ([]DeviceInfo, error) {
  196. rows, err := q.query(ctx, q.listDeviceInfosStmt, listDeviceInfos)
  197. if err != nil {
  198. return nil, err
  199. }
  200. defer rows.Close()
  201. items := []DeviceInfo{}
  202. for rows.Next() {
  203. var i DeviceInfo
  204. if err := rows.Scan(&i.ID, &i.Kind, &i.Data); err != nil {
  205. return nil, err
  206. }
  207. items = append(items, i)
  208. }
  209. if err := rows.Close(); err != nil {
  210. return nil, err
  211. }
  212. if err := rows.Err(); err != nil {
  213. return nil, err
  214. }
  215. return items, nil
  216. }
  217. const replaceDeviceAssignment = `-- name: ReplaceDeviceAssignment :exec
  218. REPLACE INTO device_assignment (id, created_date, ` + "`" + `match` + "`" + `, effect)
  219. VALUES (?, ?, ?, ?)
  220. `
  221. type ReplaceDeviceAssignmentParams struct {
  222. ID uuid.UUID
  223. CreatedDate time.Time
  224. Match string
  225. Effect json.RawMessage
  226. }
  227. func (q *Queries) ReplaceDeviceAssignment(ctx context.Context, arg ReplaceDeviceAssignmentParams) error {
  228. _, err := q.exec(ctx, q.replaceDeviceAssignmentStmt, replaceDeviceAssignment,
  229. arg.ID,
  230. arg.CreatedDate,
  231. arg.Match,
  232. arg.Effect,
  233. )
  234. return err
  235. }
  236. const replaceDeviceAuth = `-- name: ReplaceDeviceAuth :exec
  237. REPLACE INTO device_auth (id, api_key, extras)
  238. VALUES (?, ?, ?)
  239. `
  240. type ReplaceDeviceAuthParams struct {
  241. ID string
  242. ApiKey string
  243. Extras json.RawMessage
  244. }
  245. func (q *Queries) ReplaceDeviceAuth(ctx context.Context, arg ReplaceDeviceAuthParams) error {
  246. _, err := q.exec(ctx, q.replaceDeviceAuthStmt, replaceDeviceAuth, arg.ID, arg.ApiKey, arg.Extras)
  247. return err
  248. }
  249. const replaceDeviceInfo = `-- name: ReplaceDeviceInfo :exec
  250. REPLACE INTO device_info (id, kind, data)
  251. VALUES (?, ?, ?)
  252. `
  253. type ReplaceDeviceInfoParams struct {
  254. ID string
  255. Kind string
  256. Data json.RawMessage
  257. }
  258. func (q *Queries) ReplaceDeviceInfo(ctx context.Context, arg ReplaceDeviceInfoParams) error {
  259. _, err := q.exec(ctx, q.replaceDeviceInfoStmt, replaceDeviceInfo, arg.ID, arg.Kind, arg.Data)
  260. return err
  261. }