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.

301 lines
6.9 KiB

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. `
  98. type InsertDeviceAliasParams struct {
  99. ID string
  100. Alias string
  101. }
  102. func (q *Queries) InsertDeviceAlias(ctx context.Context, arg InsertDeviceAliasParams) error {
  103. _, err := q.exec(ctx, q.insertDeviceAliasStmt, insertDeviceAlias, arg.ID, arg.Alias)
  104. return err
  105. }
  106. const listDeviceAliases = `-- name: ListDeviceAliases :many
  107. SELECT id, alias
  108. FROM device_alias
  109. `
  110. func (q *Queries) ListDeviceAliases(ctx context.Context) ([]DeviceAlias, error) {
  111. rows, err := q.query(ctx, q.listDeviceAliasesStmt, listDeviceAliases)
  112. if err != nil {
  113. return nil, err
  114. }
  115. defer rows.Close()
  116. items := []DeviceAlias{}
  117. for rows.Next() {
  118. var i DeviceAlias
  119. if err := rows.Scan(&i.ID, &i.Alias); err != nil {
  120. return nil, err
  121. }
  122. items = append(items, i)
  123. }
  124. if err := rows.Close(); err != nil {
  125. return nil, err
  126. }
  127. if err := rows.Err(); err != nil {
  128. return nil, err
  129. }
  130. return items, nil
  131. }
  132. const listDeviceAssignments = `-- name: ListDeviceAssignments :many
  133. SELECT id, created_date, ` + "`" + `match` + "`" + `, effect
  134. FROM device_assignment
  135. ORDER BY created_date
  136. `
  137. func (q *Queries) ListDeviceAssignments(ctx context.Context) ([]DeviceAssignment, error) {
  138. rows, err := q.query(ctx, q.listDeviceAssignmentsStmt, listDeviceAssignments)
  139. if err != nil {
  140. return nil, err
  141. }
  142. defer rows.Close()
  143. items := []DeviceAssignment{}
  144. for rows.Next() {
  145. var i DeviceAssignment
  146. if err := rows.Scan(
  147. &i.ID,
  148. &i.CreatedDate,
  149. &i.Match,
  150. &i.Effect,
  151. ); err != nil {
  152. return nil, err
  153. }
  154. items = append(items, i)
  155. }
  156. if err := rows.Close(); err != nil {
  157. return nil, err
  158. }
  159. if err := rows.Err(); err != nil {
  160. return nil, err
  161. }
  162. return items, nil
  163. }
  164. const listDeviceAuth = `-- name: ListDeviceAuth :many
  165. SELECT id, api_key, extras
  166. FROM device_auth
  167. `
  168. func (q *Queries) ListDeviceAuth(ctx context.Context) ([]DeviceAuth, error) {
  169. rows, err := q.query(ctx, q.listDeviceAuthStmt, listDeviceAuth)
  170. if err != nil {
  171. return nil, err
  172. }
  173. defer rows.Close()
  174. items := []DeviceAuth{}
  175. for rows.Next() {
  176. var i DeviceAuth
  177. if err := rows.Scan(&i.ID, &i.ApiKey, &i.Extras); err != nil {
  178. return nil, err
  179. }
  180. items = append(items, i)
  181. }
  182. if err := rows.Close(); err != nil {
  183. return nil, err
  184. }
  185. if err := rows.Err(); err != nil {
  186. return nil, err
  187. }
  188. return items, nil
  189. }
  190. const listDeviceInfos = `-- name: ListDeviceInfos :many
  191. SELECT id, kind, data
  192. FROM device_info
  193. `
  194. func (q *Queries) ListDeviceInfos(ctx context.Context) ([]DeviceInfo, error) {
  195. rows, err := q.query(ctx, q.listDeviceInfosStmt, listDeviceInfos)
  196. if err != nil {
  197. return nil, err
  198. }
  199. defer rows.Close()
  200. items := []DeviceInfo{}
  201. for rows.Next() {
  202. var i DeviceInfo
  203. if err := rows.Scan(&i.ID, &i.Kind, &i.Data); err != nil {
  204. return nil, err
  205. }
  206. items = append(items, i)
  207. }
  208. if err := rows.Close(); err != nil {
  209. return nil, err
  210. }
  211. if err := rows.Err(); err != nil {
  212. return nil, err
  213. }
  214. return items, nil
  215. }
  216. const replaceDeviceAssignment = `-- name: ReplaceDeviceAssignment :exec
  217. REPLACE INTO device_assignment (id, created_date, ` + "`" + `match` + "`" + `, effect)
  218. VALUES (?, ?, ?, ?)
  219. `
  220. type ReplaceDeviceAssignmentParams struct {
  221. ID uuid.UUID
  222. CreatedDate time.Time
  223. Match string
  224. Effect json.RawMessage
  225. }
  226. func (q *Queries) ReplaceDeviceAssignment(ctx context.Context, arg ReplaceDeviceAssignmentParams) error {
  227. _, err := q.exec(ctx, q.replaceDeviceAssignmentStmt, replaceDeviceAssignment,
  228. arg.ID,
  229. arg.CreatedDate,
  230. arg.Match,
  231. arg.Effect,
  232. )
  233. return err
  234. }
  235. const replaceDeviceAuth = `-- name: ReplaceDeviceAuth :exec
  236. REPLACE INTO device_auth (id, api_key, extras)
  237. VALUES (?, ?, ?)
  238. `
  239. type ReplaceDeviceAuthParams struct {
  240. ID string
  241. ApiKey string
  242. Extras json.RawMessage
  243. }
  244. func (q *Queries) ReplaceDeviceAuth(ctx context.Context, arg ReplaceDeviceAuthParams) error {
  245. _, err := q.exec(ctx, q.replaceDeviceAuthStmt, replaceDeviceAuth, arg.ID, arg.ApiKey, arg.Extras)
  246. return err
  247. }
  248. const replaceDeviceInfo = `-- name: ReplaceDeviceInfo :exec
  249. REPLACE INTO device_info (id, kind, data)
  250. VALUES (?, ?, ?)
  251. `
  252. type ReplaceDeviceInfoParams struct {
  253. ID string
  254. Kind string
  255. Data json.RawMessage
  256. }
  257. func (q *Queries) ReplaceDeviceInfo(ctx context.Context, arg ReplaceDeviceInfoParams) error {
  258. _, err := q.exec(ctx, q.replaceDeviceInfoStmt, replaceDeviceInfo, arg.ID, arg.Kind, arg.Data)
  259. return err
  260. }