@@ -15,6 +15,7 @@ HOME_DIR=$7
15
15
synchProject=$8
16
16
source_type=$9
17
17
inlcudeAllReferenceData=${10}
18
+ envTypes=${11}
18
19
debug=${@: -1}
19
20
20
21
if [ -z " $LOCAL_DEV_URL " ]; then
@@ -56,7 +57,14 @@ debug=${@: -1}
56
57
echo " Missing template parameter source_type"
57
58
exit 1
58
59
fi
59
-
60
+ if [ -z " $inlcudeAllReferenceData " ]; then
61
+ echo " Missing template parameter inlcudeAllReferenceData"
62
+ exit 1
63
+ fi
64
+ if [ -z " $envTypes " ]; then
65
+ echo " Missing template parameter envTypes"
66
+ exit 1
67
+ fi
60
68
if [ " $debug " == " debug" ]; then
61
69
echo " ******* Running in Debug mode ******"
62
70
fi
@@ -113,9 +121,7 @@ function exportSingleReferenceData () {
113
121
metadataJson=$( echo " $metadataJson " | jq ' del(.columnNames, .dataRecords, .revisionData)' )
114
122
echo " $metadataJson " > metadata.json
115
123
echo " $datajson " > ${source_type} .csv
116
- cp -n ./${source_type} .csv dev.csv
117
- cp -n ./${source_type} .csv qa.csv
118
- cp -n ./${source_type} .csv prod.csv
124
+ configPerEnv . ${envTypes} " referenceData" ${source_type} .csv
119
125
cd -
120
126
fi
121
127
cd ${HOME_DIR} /${repoName}
@@ -173,6 +179,28 @@ function exportReferenceData (){
173
179
cd ${HOME_DIR} /${repoName}
174
180
}
175
181
182
+ function configPerEnv(){
183
+ localtion=$1
184
+ envTypes=$2
185
+ configType=$3
186
+ sourceFile=$4
187
+ key=$5
188
+
189
+ IFS=, read -ra values <<< " $envTypes"
190
+ for v in " ${values[@]} "
191
+ do
192
+ # things with "$v"
193
+ if [ ${configType} == " referenceData" ]; then
194
+ cp ./$sourceFile ./$v .csv
195
+ else
196
+ if [ ${configType} == " project_parameter" ]; then
197
+ cp ./$sourceFile ./${key} _${v} .json
198
+ fi
199
+ fi
200
+ done
201
+
202
+ }
203
+
176
204
function exportAsset(){
177
205
178
206
LOCAL_DEV_URL=$1
@@ -216,22 +244,28 @@ function exportAsset(){
216
244
echod " Rest_API Export:" ${EXPORT_URL} " with JSON: " ${rest_api_json}
217
245
echod $( ls -ltr)
218
246
else
219
- if [[ $assetType = workflow * ]]; then
247
+ if [[ $assetType = project_parameter * ]]; then
220
248
echod $assetType
221
- EXPORT_URL=${LOCAL_DEV_URL} /apis/v1/rest/projects/${repoName} /workflows/${assetID} /export
222
- cd ${HOME_DIR} /${repoName}
223
- mkdir -p ./assets/workflows
224
- cd ./assets/workflows
225
- echod " Workflow Export:" ${EXPORT_URL}
226
- echod $( ls -ltr)
249
+ exportProjectParameters ${LOCAL_DEV_URL} ${admin_user} ${admin_password} ${repoName} ${assetID} ${assetType} ${HOME_DIR} ${synchProject} ${inlcudeAllReferenceData}
250
+ return
227
251
else
228
- if [[ $assetType = flowservice* ]]; then
229
- EXPORT_URL=${LOCAL_DEV_URL} /apis/v1/rest/projects/${repoName} /flows/${assetID} /export
252
+ if [[ $assetType = workflow* ]]; then
253
+ echod $assetType
254
+ EXPORT_URL=${LOCAL_DEV_URL} /apis/v1/rest/projects/${repoName} /workflows/${assetID} /export
230
255
cd ${HOME_DIR} /${repoName}
231
- mkdir -p ./assets/flowservices
232
- cd ./assets/flowservices
233
- echo " Flowservice Export:" ${EXPORT_URL}
256
+ mkdir -p ./assets/workflows
257
+ cd ./assets/workflows
258
+ echod " Workflow Export:" ${EXPORT_URL}
234
259
echod $( ls -ltr)
260
+ else
261
+ if [[ $assetType = flowservice* ]]; then
262
+ EXPORT_URL=${LOCAL_DEV_URL} /apis/v1/rest/projects/${repoName} /flows/${assetID} /export
263
+ cd ${HOME_DIR} /${repoName}
264
+ mkdir -p ./assets/flowservices
265
+ cd ./assets/flowservices
266
+ echo " Flowservice Export:" ${EXPORT_URL}
267
+ echod $( ls -ltr)
268
+ fi
235
269
fi
236
270
fi
237
271
fi
@@ -246,7 +280,6 @@ function exportAsset(){
246
280
--header ' Accept: application/json' \
247
281
-u ${admin_user} :${admin_password} )
248
282
fi
249
-
250
283
downloadURL=$( echo " $linkJson " | jq -r ' .output.download_link' )
251
284
252
285
regex=' (https?|ftp|file)://[-[:alnum:]\+&@#/%?=~_|!:,.;]*[-[:alnum:]\+&@#/%=~_|]'
@@ -278,6 +311,74 @@ function exportAsset(){
278
311
279
312
}
280
313
314
+ function exportProjectParameters(){
315
+
316
+ LOCAL_DEV_URL=$1
317
+ admin_user=$2
318
+ admin_password=$3
319
+ repoName=$4
320
+ assetID=$5
321
+ assetType=$6
322
+ HOME_DIR=$7
323
+ synchProject=$8
324
+ inlcudeAllReferenceData=$9
325
+
326
+ if [ ${synchProject} == true ]; then
327
+ PROJECT_PARAM_GET_URL=${LOCAL_DEV_URL} /apis/v1/rest/projects/${repoName} /params
328
+ else
329
+ PROJECT_PARAM_GET_URL=${LOCAL_DEV_URL} /apis/v1/rest/projects/${repoName} /params/${assetID}
330
+ fi
331
+
332
+ ppListJson=$( curl --location --request GET ${PROJECT_PARAM_GET_URL} \
333
+ --header ' Content-Type: application/json' \
334
+ --header ' Accept: application/json' \
335
+ -u ${admin_user} :${admin_password} )
336
+
337
+ ppListExport=$( echo " $ppListJson " | jq ' . // empty' )
338
+
339
+ if [ -z " $ppListExport " ]; then
340
+ echo " No Project Parameters retreived:" ${ppListJson}
341
+ else
342
+ mkdir -p ./assets/projectConfigs/parameters
343
+ cd ./assets/projectConfigs/parameters
344
+ if [ ${synchProject} != true ]; then
345
+ parameterUID=$( jq -r ' .output.uid' <<< " $ppListJson" )
346
+ mkdir -p ./${parameterUID}
347
+ cd ./${parameterUID}
348
+ data=$( jq -r ' .output.param' <<< " $ppListJson" )
349
+ key=$( jq -r ' .output.param.key' <<< " $ppListJson" )
350
+ metadataJson=' { "uid":"' ${parameterUID} ' " }'
351
+ echo ${metadataJson} > ./metadata.json
352
+ echo ${data} > ./${key} _${source_type} .json
353
+ configPerEnv . ${envTypes} " project_parameter" ${key} _${source_type} .json ${key}
354
+ # cp -n ./${key}_${source_type}.json ${key}_dev.json
355
+ # cp -n ./${key}_${source_type}.json ${key}_qa.json
356
+ # cp -n ./${key}_${source_type}.json ${key}_prod.json
357
+ cd ..
358
+ else
359
+ for item in $( jq -c -r ' .output[]' <<< " $ppListJson" ) ; do
360
+ echod " Inside Parameters Loop"
361
+ parameterUID=$( jq -r ' .uid' <<< " $item" )
362
+ mkdir -p ./${parameterUID}
363
+ cd ./${parameterUID}
364
+ data=$( jq -r ' .param' <<< " $item" )
365
+ key=$( jq -r ' .param.key' <<< " $item" )
366
+ metadataJson=' { "uid":"' ${parameterUID} ' " }'
367
+ echo ${metadataJson} > ./metadata.json
368
+ echo ${data} > ./${key} _${source_type} .json
369
+ configPerEnv . ${envTypes} " project_parameter" ${key} _${source_type} .json ${key}
370
+ # cp -n ./${key}_${source_type}.json ${key}_dev.json
371
+ # cp -n ./${key}_${source_type}.json ${key}_qa.json
372
+ # cp -n ./${key}_${source_type}.json ${key}_prod.json
373
+ cd ..
374
+ done
375
+ fi
376
+ echo " Project Parameters export Succeeded"
377
+ fi
378
+ cd ${HOME_DIR} /${repoName}
379
+ }
380
+
381
+
281
382
if [ ${synchProject} == true ]; then
282
383
echod " Listing All Assets"
283
384
echod $assetType
@@ -288,7 +389,7 @@ if [ ${synchProject} == true ]; then
288
389
--header ' Accept: application/json' \
289
390
-u ${admin_user} :${admin_password} )
290
391
291
- # Exporing APIs
392
+ # Exporting APIs
292
393
for item in $( jq -c -r ' .output.rest_api[]' <<< " $projectListJson" ) ; do
293
394
echod " Inside REST_API Loop"
294
395
assetID=$item
@@ -297,7 +398,7 @@ if [ ${synchProject} == true ]; then
297
398
exportAsset ${LOCAL_DEV_URL} ${admin_user} ${admin_password} ${repoName} ${assetID} ${assetType} ${HOME_DIR} ${synchProject} ${inlcudeAllReferenceData}
298
399
done
299
400
300
- # Exporing Workflows
401
+ # Exporting Workflows
301
402
for item in $( jq -c -r ' .output.workflows[]' <<< " $projectListJson" ) ; do
302
403
echod " Inside Workflow Loop"
303
404
assetID=$item
@@ -339,34 +440,11 @@ if [ ${synchProject} == true ]; then
339
440
# Exporting Project Referencedata
340
441
341
442
exportReferenceData ${LOCAL_DEV_URL} ${admin_user} ${admin_password} ${repoName} ${assetID} ${assetType} ${HOME_DIR}
342
-
343
-
344
443
# Exporting Project Parameters
345
- : ' PP Export
346
- PROJECT_PARAM_GET_URL=${LOCAL_DEV_URL}/apis/v1/rest/projects/${repoName}/params
347
-
348
- ppListJson=$(curl --location --request GET ${PROJECT_PARAM_GET_URL} \
349
- --header ' Content-Type: application/json' \
350
- --header ' Accept: application/json' \
351
- -u ${admin_user}:${admin_password})
352
-
353
- ppListExport=$(echo "$ppListJson" | jq ' . // empty' )
354
-
355
- if [ -z "$ppListExport" ]; then
356
- echo "No Project Parameters retreived:" ${ppListJson}
357
- else
358
- mkdir -p ./assets/projectConfigs/parameters
359
- cd ./assets/projectConfigs/parameters
360
- for item in $(jq -c -r ' .output[]' <<< "$ppListJson"); do
361
- echod "Inside Parameters Loop"
362
- parameterUID=$(jq -r ' .uid' <<< "$item")
363
- data=$(jq -r ' .param' <<< "$item")
364
- echo ${data} > ./${parameterUID}.json
365
- done
366
- echo "Project Parameters export Succeeded"
367
- fi
368
- cd ${HOME_DIR}/${repoName}
369
- '
444
+ # PP Export
445
+ assetType=project_parameter
446
+ exportAsset ${LOCAL_DEV_URL} ${admin_user} ${admin_password} ${repoName} ${assetID} ${assetType} ${HOME_DIR} ${synchProject} ${inlcudeAllReferenceData}
447
+
370
448
else
371
449
exportAsset ${LOCAL_DEV_URL} ${admin_user} ${admin_password} ${repoName} ${assetID} ${assetType} ${HOME_DIR} ${synchProject} ${inlcudeAllReferenceData}
372
450
fi
0 commit comments