-
Notifications
You must be signed in to change notification settings - Fork 370
Expand file tree
/
Copy pathget_team.sql.go
More file actions
255 lines (236 loc) · 7.97 KB
/
Copy pathget_team.sql.go
File metadata and controls
255 lines (236 loc) · 7.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: get_team.sql
package authqueries
import (
"context"
"github.com/google/uuid"
)
const getAutoJoinTeamsBySSOOrganizationID = `-- name: GetAutoJoinTeamsBySSOOrganizationID :many
SELECT t.id, t.created_at, t.is_blocked, t.name, t.tier, t.email, t.is_banned, t.blocked_reason, t.cluster_id, t.sandbox_scheduling_labels, t.sso_organization_id, t.sso_auto_join, t.slug
FROM "public"."teams" t
WHERE t.sso_organization_id = $1::uuid
AND t.sso_auto_join = true
AND t.is_blocked = false
AND t.is_banned = false
ORDER BY t.created_at ASC
`
type GetAutoJoinTeamsBySSOOrganizationIDRow struct {
Team Team
}
func (q *Queries) GetAutoJoinTeamsBySSOOrganizationID(ctx context.Context, ssoOrganizationID uuid.UUID) ([]GetAutoJoinTeamsBySSOOrganizationIDRow, error) {
rows, err := q.db.Query(ctx, getAutoJoinTeamsBySSOOrganizationID, ssoOrganizationID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []GetAutoJoinTeamsBySSOOrganizationIDRow
for rows.Next() {
var i GetAutoJoinTeamsBySSOOrganizationIDRow
if err := rows.Scan(
&i.Team.ID,
&i.Team.CreatedAt,
&i.Team.IsBlocked,
&i.Team.Name,
&i.Team.Tier,
&i.Team.Email,
&i.Team.IsBanned,
&i.Team.BlockedReason,
&i.Team.ClusterID,
&i.Team.SandboxSchedulingLabels,
&i.Team.SsoOrganizationID,
&i.Team.SsoAutoJoin,
&i.Team.Slug,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getTeamWithTierByAPIKey = `-- name: GetTeamWithTierByAPIKey :one
SELECT t.id, t.created_at, t.is_blocked, t.name, t.tier, t.email, t.is_banned, t.blocked_reason, t.cluster_id, t.sandbox_scheduling_labels, t.sso_organization_id, t.sso_auto_join, t.slug, tl.id, tl.max_length_hours, tl.concurrent_sandboxes, tl.concurrent_template_builds, tl.max_vcpu, tl.max_ram_mb, tl.disk_mb, tl.events_ttl_days, tl.default_free_disk_size_mb, tl.max_disk_size_mb FROM "public"."team_api_keys" tak
JOIN "public"."teams" t ON tak.team_id = t.id
JOIN "public"."team_limits" tl on tl.id = t.id
WHERE tak.team_id = t.id
AND tak.api_key_hash = $1
`
type GetTeamWithTierByAPIKeyRow struct {
Team Team
TeamLimit TeamLimit
}
func (q *Queries) GetTeamWithTierByAPIKey(ctx context.Context, apiKeyHash string) (GetTeamWithTierByAPIKeyRow, error) {
row := q.db.QueryRow(ctx, getTeamWithTierByAPIKey, apiKeyHash)
var i GetTeamWithTierByAPIKeyRow
err := row.Scan(
&i.Team.ID,
&i.Team.CreatedAt,
&i.Team.IsBlocked,
&i.Team.Name,
&i.Team.Tier,
&i.Team.Email,
&i.Team.IsBanned,
&i.Team.BlockedReason,
&i.Team.ClusterID,
&i.Team.SandboxSchedulingLabels,
&i.Team.SsoOrganizationID,
&i.Team.SsoAutoJoin,
&i.Team.Slug,
&i.TeamLimit.ID,
&i.TeamLimit.MaxLengthHours,
&i.TeamLimit.ConcurrentSandboxes,
&i.TeamLimit.ConcurrentTemplateBuilds,
&i.TeamLimit.MaxVcpu,
&i.TeamLimit.MaxRamMb,
&i.TeamLimit.DiskMb,
&i.TeamLimit.EventsTtlDays,
&i.TeamLimit.DefaultFreeDiskSizeMb,
&i.TeamLimit.MaxDiskSizeMb,
)
return i, err
}
const getTeamWithTierByTeamAndUser = `-- name: GetTeamWithTierByTeamAndUser :one
SELECT t.id, t.created_at, t.is_blocked, t.name, t.tier, t.email, t.is_banned, t.blocked_reason, t.cluster_id, t.sandbox_scheduling_labels, t.sso_organization_id, t.sso_auto_join, t.slug, tl.id, tl.max_length_hours, tl.concurrent_sandboxes, tl.concurrent_template_builds, tl.max_vcpu, tl.max_ram_mb, tl.disk_mb, tl.events_ttl_days, tl.default_free_disk_size_mb, tl.max_disk_size_mb
FROM "public"."teams" t
JOIN "public"."users_teams" ut ON ut.team_id = t.id
JOIN "public"."team_limits" tl on tl.id = t.id
WHERE ut.user_id = $1 AND t.id = $2
`
type GetTeamWithTierByTeamAndUserParams struct {
UserID uuid.UUID
ID uuid.UUID
}
type GetTeamWithTierByTeamAndUserRow struct {
Team Team
TeamLimit TeamLimit
}
func (q *Queries) GetTeamWithTierByTeamAndUser(ctx context.Context, arg GetTeamWithTierByTeamAndUserParams) (GetTeamWithTierByTeamAndUserRow, error) {
row := q.db.QueryRow(ctx, getTeamWithTierByTeamAndUser, arg.UserID, arg.ID)
var i GetTeamWithTierByTeamAndUserRow
err := row.Scan(
&i.Team.ID,
&i.Team.CreatedAt,
&i.Team.IsBlocked,
&i.Team.Name,
&i.Team.Tier,
&i.Team.Email,
&i.Team.IsBanned,
&i.Team.BlockedReason,
&i.Team.ClusterID,
&i.Team.SandboxSchedulingLabels,
&i.Team.SsoOrganizationID,
&i.Team.SsoAutoJoin,
&i.Team.Slug,
&i.TeamLimit.ID,
&i.TeamLimit.MaxLengthHours,
&i.TeamLimit.ConcurrentSandboxes,
&i.TeamLimit.ConcurrentTemplateBuilds,
&i.TeamLimit.MaxVcpu,
&i.TeamLimit.MaxRamMb,
&i.TeamLimit.DiskMb,
&i.TeamLimit.EventsTtlDays,
&i.TeamLimit.DefaultFreeDiskSizeMb,
&i.TeamLimit.MaxDiskSizeMb,
)
return i, err
}
const getTeamWithTierByTeamID = `-- name: GetTeamWithTierByTeamID :one
SELECT t.id, t.created_at, t.is_blocked, t.name, t.tier, t.email, t.is_banned, t.blocked_reason, t.cluster_id, t.sandbox_scheduling_labels, t.sso_organization_id, t.sso_auto_join, t.slug, tl.id, tl.max_length_hours, tl.concurrent_sandboxes, tl.concurrent_template_builds, tl.max_vcpu, tl.max_ram_mb, tl.disk_mb, tl.events_ttl_days, tl.default_free_disk_size_mb, tl.max_disk_size_mb
FROM "public"."teams" t
JOIN "public"."team_limits" tl on tl.id = t.id
WHERE t.id = $1
`
type GetTeamWithTierByTeamIDRow struct {
Team Team
TeamLimit TeamLimit
}
func (q *Queries) GetTeamWithTierByTeamID(ctx context.Context, id uuid.UUID) (GetTeamWithTierByTeamIDRow, error) {
row := q.db.QueryRow(ctx, getTeamWithTierByTeamID, id)
var i GetTeamWithTierByTeamIDRow
err := row.Scan(
&i.Team.ID,
&i.Team.CreatedAt,
&i.Team.IsBlocked,
&i.Team.Name,
&i.Team.Tier,
&i.Team.Email,
&i.Team.IsBanned,
&i.Team.BlockedReason,
&i.Team.ClusterID,
&i.Team.SandboxSchedulingLabels,
&i.Team.SsoOrganizationID,
&i.Team.SsoAutoJoin,
&i.Team.Slug,
&i.TeamLimit.ID,
&i.TeamLimit.MaxLengthHours,
&i.TeamLimit.ConcurrentSandboxes,
&i.TeamLimit.ConcurrentTemplateBuilds,
&i.TeamLimit.MaxVcpu,
&i.TeamLimit.MaxRamMb,
&i.TeamLimit.DiskMb,
&i.TeamLimit.EventsTtlDays,
&i.TeamLimit.DefaultFreeDiskSizeMb,
&i.TeamLimit.MaxDiskSizeMb,
)
return i, err
}
const getTeamsWithUsersTeamsWithTier = `-- name: GetTeamsWithUsersTeamsWithTier :many
SELECT t.id, t.created_at, t.is_blocked, t.name, t.tier, t.email, t.is_banned, t.blocked_reason, t.cluster_id, t.sandbox_scheduling_labels, t.sso_organization_id, t.sso_auto_join, t.slug, ut.is_default, tl.id, tl.max_length_hours, tl.concurrent_sandboxes, tl.concurrent_template_builds, tl.max_vcpu, tl.max_ram_mb, tl.disk_mb, tl.events_ttl_days, tl.default_free_disk_size_mb, tl.max_disk_size_mb
FROM "public"."teams" t
JOIN "public"."users_teams" ut ON ut.team_id = t.id
JOIN "public"."team_limits" tl on tl.id = t.id
WHERE ut.user_id = $1
`
type GetTeamsWithUsersTeamsWithTierRow struct {
Team Team
IsDefault bool
TeamLimit TeamLimit
}
func (q *Queries) GetTeamsWithUsersTeamsWithTier(ctx context.Context, userID uuid.UUID) ([]GetTeamsWithUsersTeamsWithTierRow, error) {
rows, err := q.db.Query(ctx, getTeamsWithUsersTeamsWithTier, userID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []GetTeamsWithUsersTeamsWithTierRow
for rows.Next() {
var i GetTeamsWithUsersTeamsWithTierRow
if err := rows.Scan(
&i.Team.ID,
&i.Team.CreatedAt,
&i.Team.IsBlocked,
&i.Team.Name,
&i.Team.Tier,
&i.Team.Email,
&i.Team.IsBanned,
&i.Team.BlockedReason,
&i.Team.ClusterID,
&i.Team.SandboxSchedulingLabels,
&i.Team.SsoOrganizationID,
&i.Team.SsoAutoJoin,
&i.Team.Slug,
&i.IsDefault,
&i.TeamLimit.ID,
&i.TeamLimit.MaxLengthHours,
&i.TeamLimit.ConcurrentSandboxes,
&i.TeamLimit.ConcurrentTemplateBuilds,
&i.TeamLimit.MaxVcpu,
&i.TeamLimit.MaxRamMb,
&i.TeamLimit.DiskMb,
&i.TeamLimit.EventsTtlDays,
&i.TeamLimit.DefaultFreeDiskSizeMb,
&i.TeamLimit.MaxDiskSizeMb,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}