-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex-users-from-google.bpmn
255 lines (255 loc) · 13.8 KB
/
index-users-from-google.bpmn
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
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0sdny8d" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.5.0">
<bpmn:process id="index_users_google" isExecutable="true">
<bpmn:startEvent id="start" name="Start">
<bpmn:outgoing>Flow_1if56ls</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_1if56ls" sourceRef="start" targetRef="settings" />
<bpmn:endEvent id="end" name="End">
<bpmn:incoming>Flow_0dmy4ld</bpmn:incoming>
</bpmn:endEvent>
<bpmn:scriptTask id="jwt" name="Generate signed JWT" scriptFormat="javascript" camunda:resultVariable="signedJWT" camunda:resource="/scripts/google/google_auth.js">
<bpmn:incoming>Flow_0riv0em</bpmn:incoming>
<bpmn:outgoing>Flow_1oaj2n2</bpmn:outgoing>
</bpmn:scriptTask>
<bpmn:sequenceFlow id="Flow_1oaj2n2" sourceRef="jwt" targetRef="token" />
<bpmn:sequenceFlow id="Flow_1tzk6fw" sourceRef="token" targetRef="users" />
<bpmn:serviceTask id="token" name="Generate Google access token">
<bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
<camunda:inputParameter name="responseType">json</camunda:inputParameter>
<camunda:inputParameter name="method">POST</camunda:inputParameter>
<camunda:inputParameter name="body">grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=${environment.output.signedJWT}</camunda:inputParameter>
<camunda:inputParameter name="headers">
<camunda:map>
<camunda:entry key="Content-Type">application/x-www-form-urlencoded</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:inputParameter name="url">https://oauth2.googleapis.com/token</camunda:inputParameter>
<camunda:outputParameter name="body">${body}</camunda:outputParameter>
</camunda:inputOutput>
<camunda:connectorId>httpRequest</camunda:connectorId>
</camunda:connector>
<camunda:inputOutput>
<camunda:outputParameter name="accessToken">${content.output.body.access_token}</camunda:outputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1oaj2n2</bpmn:incoming>
<bpmn:outgoing>Flow_1tzk6fw</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:serviceTask id="users" name="Get users in Google">
<bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
<camunda:inputParameter name="responseType">json</camunda:inputParameter>
<camunda:inputParameter name="headers">
<camunda:map>
<camunda:entry key="Authorization">Bearer ${environment.output.accessToken}</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:inputParameter name="url">https://admin.googleapis.com/admin/directory/v1/users?customer=${environment.output.googleSettings._google_customerid}&maxResults=500&pageToken=${environment.output.googleUsers.nextPageToken}</camunda:inputParameter>
<camunda:outputParameter name="body">${body}</camunda:outputParameter>
</camunda:inputOutput>
<camunda:connectorId>httpRequest</camunda:connectorId>
</camunda:connector>
<camunda:inputOutput>
<camunda:outputParameter name="googleUsers">${content.output.body}</camunda:outputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1tzk6fw</bpmn:incoming>
<bpmn:incoming>Flow_0rhygb6</bpmn:incoming>
<bpmn:outgoing>Flow_0cejro8</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_0cejro8" sourceRef="users" targetRef="transform" />
<bpmn:exclusiveGateway id="more_users" name="Get more users?" default="Flow_0dmy4ld">
<bpmn:incoming>Flow_107evtk</bpmn:incoming>
<bpmn:outgoing>Flow_0dmy4ld</bpmn:outgoing>
<bpmn:outgoing>Flow_0rhygb6</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:sequenceFlow id="Flow_0dmy4ld" name="No" sourceRef="more_users" targetRef="end" />
<bpmn:sequenceFlow id="Flow_0rhygb6" name="Yes" sourceRef="more_users" targetRef="users">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression" language="javascript">next(null, environment.output.googleUsers && environment.output.googleUsers.nextPageToken);</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:scriptTask id="transform" name="Transform users to items" scriptFormat="javascript" camunda:resultVariable="userItems" camunda:resource="/scripts/google/transform_users.js">
<bpmn:incoming>Flow_0cejro8</bpmn:incoming>
<bpmn:outgoing>Flow_1e91ljz</bpmn:outgoing>
</bpmn:scriptTask>
<bpmn:sequenceFlow id="Flow_1e91ljz" sourceRef="transform" targetRef="bulk" />
<bpmn:serviceTask id="bulk" name="Bulk index items">
<bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
<camunda:inputParameter name="payload">${environment.output.userItems}</camunda:inputParameter>
<camunda:inputParameter name="method">POST</camunda:inputParameter>
<camunda:inputParameter name="url">/admin/bulk/items</camunda:inputParameter>
</camunda:inputOutput>
<camunda:connectorId>onifyApiRequest</camunda:connectorId>
</camunda:connector>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1e91ljz</bpmn:incoming>
<bpmn:outgoing>Flow_107evtk</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_107evtk" sourceRef="bulk" targetRef="more_users" />
<bpmn:serviceTask id="settings" name="Get Google settings">
<bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
<camunda:inputParameter name="query">
<camunda:map>
<camunda:entry key="tag">google</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:inputParameter name="url">/my/config/settings</camunda:inputParameter>
</camunda:inputOutput>
<camunda:connectorId>onifyApiRequest</camunda:connectorId>
</camunda:connector>
<camunda:inputOutput>
<camunda:outputParameter name="googleSettings">${content.output.body}</camunda:outputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1if56ls</bpmn:incoming>
<bpmn:outgoing>Flow_0riv0em</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_0riv0em" sourceRef="settings" targetRef="jwt" />
<bpmn:textAnnotation id="TextAnnotation_09b86tr">
<bpmn:text>Get Google service account settings from Onify API</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="Association_03q03nv" sourceRef="settings" targetRef="TextAnnotation_09b86tr" />
<bpmn:textAnnotation id="TextAnnotation_0j8gdcc">
<bpmn:text>Generate claim and generate JWT</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="Association_0pp1ogn" sourceRef="jwt" targetRef="TextAnnotation_0j8gdcc" />
<bpmn:textAnnotation id="TextAnnotation_14qrud4">
<bpmn:text>Generate access token with ttl 60 min</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="Association_1tpuxgn" sourceRef="token" targetRef="TextAnnotation_14qrud4" />
<bpmn:textAnnotation id="TextAnnotation_1lf8ifh">
<bpmn:text>Get users from selected customer. 500 at a time</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="Association_1vuebd0" sourceRef="users" targetRef="TextAnnotation_1lf8ifh" />
<bpmn:textAnnotation id="TextAnnotation_11kisxk">
<bpmn:text>Transform users from Google to items</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="Association_02h4dok" sourceRef="transform" targetRef="TextAnnotation_11kisxk" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="index_users_google">
<bpmndi:BPMNShape id="TextAnnotation_09b86tr_di" bpmnElement="TextAnnotation_09b86tr">
<dc:Bounds x="300" y="96" width="160" height="44" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_0j8gdcc_di" bpmnElement="TextAnnotation_0j8gdcc">
<dc:Bounds x="440" y="340" width="130" height="40" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_14qrud4_di" bpmnElement="TextAnnotation_14qrud4">
<dc:Bounds x="640" y="120" width="140" height="40" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_1lf8ifh_di" bpmnElement="TextAnnotation_1lf8ifh">
<dc:Bounds x="760" y="326" width="170" height="44" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_11kisxk_di" bpmnElement="TextAnnotation_11kisxk">
<dc:Bounds x="900" y="80" width="130" height="40" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0riv0em_di" bpmnElement="Flow_0riv0em">
<di:waypoint x="340" y="247" />
<di:waypoint x="391" y="247" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_107evtk_di" bpmnElement="Flow_107evtk">
<di:waypoint x="1110" y="244" />
<di:waypoint x="1173" y="244" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1e91ljz_di" bpmnElement="Flow_1e91ljz">
<di:waypoint x="950" y="244" />
<di:waypoint x="1010" y="244" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0rhygb6_di" bpmnElement="Flow_0rhygb6">
<di:waypoint x="1198" y="219" />
<di:waypoint x="1198" y="170" />
<di:waypoint x="750" y="170" />
<di:waypoint x="750" y="207" />
<bpmndi:BPMNLabel>
<dc:Bounds x="965" y="152" width="18" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0cejro8_di" bpmnElement="Flow_0cejro8">
<di:waypoint x="800" y="244" />
<di:waypoint x="850" y="244" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1tzk6fw_di" bpmnElement="Flow_1tzk6fw">
<di:waypoint x="640" y="247" />
<di:waypoint x="700" y="247" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1oaj2n2_di" bpmnElement="Flow_1oaj2n2">
<di:waypoint x="491" y="247" />
<di:waypoint x="540" y="247" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1if56ls_di" bpmnElement="Flow_1if56ls">
<di:waypoint x="188" y="247" />
<di:waypoint x="240" y="247" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0dmy4ld_di" bpmnElement="Flow_0dmy4ld">
<di:waypoint x="1223" y="244" />
<di:waypoint x="1320" y="244" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1264" y="226" width="15" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="start">
<dc:Bounds x="152" y="229" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="158" y="272" width="24" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1mbrrq0_di" bpmnElement="token">
<dc:Bounds x="540" y="207" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1so3s6l_di" bpmnElement="users">
<dc:Bounds x="700" y="207" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1exb582_di" bpmnElement="transform">
<dc:Bounds x="850" y="204" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1uapyk9_di" bpmnElement="bulk">
<dc:Bounds x="1010" y="204" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0yibfwb_di" bpmnElement="settings">
<dc:Bounds x="240" y="207" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_19kuezu_di" bpmnElement="jwt">
<dc:Bounds x="391" y="207" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_10fxhsy_di" bpmnElement="end">
<dc:Bounds x="1320" y="226" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1328" y="269" width="20" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_0qhey1p_di" bpmnElement="more_users" isMarkerVisible="true">
<dc:Bounds x="1173" y="219" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1157" y="276" width="82" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Association_03q03nv_di" bpmnElement="Association_03q03nv">
<di:waypoint x="308" y="207" />
<di:waypoint x="337" y="140" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Association_0pp1ogn_di" bpmnElement="Association_0pp1ogn">
<di:waypoint x="459" y="287" />
<di:waypoint x="483" y="340" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Association_1tpuxgn_di" bpmnElement="Association_1tpuxgn">
<di:waypoint x="626" y="207" />
<di:waypoint x="668" y="160" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Association_1vuebd0_di" bpmnElement="Association_1vuebd0">
<di:waypoint x="776" y="287" />
<di:waypoint x="800" y="326" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Association_02h4dok_di" bpmnElement="Association_02h4dok">
<di:waypoint x="913" y="204" />
<di:waypoint x="942" y="120" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>