forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0036.yml
149 lines (149 loc) · 5.27 KB
/
0036.yml
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
version: 36
description: github integrations phase 2
migrationScript: 0036-migration.sql
downgradeScript: 0036-downgrade.sql
methods:
taskcluster_integration_owners_entities_load:
deprecated: true
description: See taskcluster-lib-entities
mode: read
serviceName: github
args: partition_key text, row_key text
returns: table (partition_key_out text, row_key_out text, value jsonb, version integer, etag uuid)
body: |-
begin
return query
select
taskcluster_integration_owners_entities_load.partition_key,
'someConstant' as row_key,
jsonb_build_object(
'PartitionKey', taskcluster_integration_owners_entities_load.partition_key,
'RowKey', 'someConstant',
'installationId', installation_id,
'owner', owner) as value,
1 as version,
public.gen_random_uuid() as etag -- we just return this for api compatibility
from github_integrations
where
github_integrations.owner = decode_string_key(taskcluster_integration_owners_entities_load.partition_key);
end
taskcluster_integration_owners_entities_create:
deprecated: true
description: See taskcluster-lib-entities
serviceName: github
mode: write
args: pk text, rk text, properties jsonb, overwrite boolean, version integer
returns: uuid
body: |-
begin
if not overwrite then
raise exception 'must allow overwrite';
end if;
insert into github_integrations (owner, installation_id) values (
(properties ->> 'owner')::text,
(properties ->> 'installationId')::integer )
on conflict (owner) do update set installation_id = (properties ->> 'installationId')::integer;
return public.gen_random_uuid(); -- we don't store this or use it so just return anything
end
taskcluster_integration_owners_entities_scan:
deprecated: true
description: See taskcluster-lib-entities
mode: read
serviceName: github
args: pk text, rk text, condition text, size integer, page integer
returns: table (partition_key text, row_key text, value jsonb, version integer, etag uuid)
body: |-
declare
begin
if not condition is null then
raise exception 'condition not supported';
end if;
if not partition_key is null then
raise exception 'can only scan entire table';
end if;
return query
select
encode_string_key(owner),
'someConstant' as row_key,
jsonb_build_object(
'PartitionKey', encode_string_key(owner),
'RowKey', 'someConstant',
'installationId', installation_id,
'owner', owner) as value,
1 as version,
public.gen_random_uuid() as etag
from github_integrations
order by owner
limit case
when (size is not null and size > 0) then size + 1
else null
end
offset case
when (page is not null and page > 0) then page
else 0
end;
end
taskcluster_integration_owners_entities_remove:
deprecated: true
serviceName: github
description: See taskcluster-lib-entities
mode: write
args: partition_key text, row_key text
returns: table (etag uuid)
body: |-
begin
delete
from github_integrations
where
github_integrations.owner = decode_string_key(partition_key);
-- tc-gh does not care if the row existed
return query select gen_random_uuid() as etag;
end
taskcluster_integration_owners_entities_modify:
deprecated: true
serviceName: github
description: See taskcluster-lib-entities
mode: write
args: partition_key text, row_key text, properties jsonb, version integer, old_etag uuid
returns: table (etag uuid)
body: |-
begin
raise exception 'github integrations are immutable';
end
upsert_github_integration:
serviceName: github
description: Create a single integration.
mode: write
args: owner_in text, installation_id_in integer
returns: void
body: |-
begin
insert into github_integrations (owner, installation_id) values (owner_in, installation_id_in)
on conflict (owner) do update set installation_id = installation_id_in;
end
get_github_integration:
serviceName: github
description: Get a single integration by owner.
mode: read
args: owner_in text
returns: table (owner text, installation_id integer)
body: |-
begin
return query select github_integrations.owner, github_integrations.installation_id from github_integrations where github_integrations.owner = owner_in;
end
get_github_integrations:
serviceName: github
description: Get a list of integrations.
mode: read
args: page_size_in integer, page_offset_in integer
returns: table (owner text, installation_id integer)
body: |-
begin
return query select
github_integrations.owner,
github_integrations.installation_id
from github_integrations
order by github_integrations.installation_id
limit get_page_limit(page_size_in)
offset get_page_offset(page_offset_in);
end