1
+ #! /bin/bash
2
+
3
+ # Copyright 2022 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # <http://www.apache.org/licenses/LICENSE-2.0>
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ echo " <h3>Company Apps</h3>" >> " $report_html "
18
+
19
+ mkdir -p " $export_folder /$organization /config/resources/edge/env/$environment /companyapps"
20
+
21
+ sackmesser list " organizations/$organization /companies" | jq -r -c ' .[]|.' | while read -r companyname; do
22
+ loginfo " download company: $companyname "
23
+ mkdir " $export_folder /$organization /config/resources/edge/env/$environment /companyapps/$companyname "
24
+ sackmesser list " organizations/$organization /companies/$companyname /apps" | jq -r -c ' .[]|.' | while read -r appId; do
25
+ loginfo " download company app: $appId for company: $companyname "
26
+ full_app=$( sackmesser list " organizations/$organization /companies/$companyname /apps/$( urlencode " $appId " ) " )
27
+ echo " $full_app " | jq ' del(.credentials)' > " $export_folder /$organization /config/resources/edge/env/$environment /companyapps/$appId " .json
28
+ echo " $full_app " | jq -r -c ' .credentials[]' | while read -r credential; do
29
+ appkey=$( echo " $credential " | jq -r ' .consumerKey' )
30
+ done
31
+ done
32
+ done
33
+
34
+ if ls " $export_folder /$organization /config/resources/edge/env/$environment /companyapps" /* .json 1> /dev/null 2>&1 ; then
35
+ jq -n ' [inputs]' " $export_folder /$organization /config/resources/edge/env/$environment /companyapps" /* .json > " $export_folder /$organization /config/resources/edge/env/$environment /companyapps" .json
36
+ fi
37
+
38
+ echo " <div><table id=\" ts-lint\" data-toggle=\" table\" class=\" table\" >" >> " $report_html "
39
+ echo " <thead class=\" thead-dark\" ><tr>" >> " $report_html "
40
+ echo " <th data-sortable=\" true\" data-field=\" name\" >Name</th>" >> " $report_html "
41
+ echo " <th data-sortable=\" true\" data-field=\" status\" >Status</th>" >> " $report_html "
42
+ echo " <th data-sortable=\" true\" data-field=\" company\" >Company Name</th>" >> " $report_html "
43
+ echo " <th data-sortable=\" true\" data-field=\" app_id\" >App ID</th>" >> " $report_html "
44
+ echo " <th data-sortable=\" true\" data-field=\" app_fam\" >App Family</th>" >> " $report_html "
45
+ echo " <th data-sortable=\" true\" data-field=\" callback\" >Callback URL</th>" >> " $report_html "
46
+ echo " <th data-sortable=\" true\" data-field=\" access\" >Access Type</th>" >> " $report_html "
47
+ echo " <th data-sortable=\" true\" data-field=\" created\" >Created At</th>" >> " $report_html "
48
+ echo " <th data-sortable=\" true\" data-field=\" modified\" >Last Modified</th>" >> " $report_html "
49
+ echo " <th data-sortable=\" true\" data-field=\" credentialsLoaded\" >Credentials Loaded</th>" >> " $report_html "
50
+ echo " <th data-sortable=\" true\" data-field=\" scopes\" >Scopes</th>" >> " $report_html "
51
+ echo " </tr></thead>" >> " $report_html "
52
+
53
+ echo " <tbody class=\" mdc-data-table__content\" >" >> " $report_html "
54
+
55
+ if [ -f " $export_folder /$organization /config/resources/edge/env/$environment /companyapps" .json ]; then
56
+ jq -c ' .[]' " $export_folder /$organization /config/resources/edge/env/$environment /companyapps" .json | while read i; do
57
+ name=$( echo " $i " | jq -r ' .name' )
58
+ status=$( echo " $i " | jq -r ' .status' )
59
+ companyName=$( echo " $i " | jq -r ' .companyName' )
60
+ appId=$( echo " $i " | jq -r ' .appId' )
61
+ appFamily=$( echo " $i " | jq -r ' .appFamily' )
62
+ callbackUrl=$( echo " $i " | jq -r ' .callbackUrl' )
63
+ accessType=$( echo " $i " | jq -r ' .accessType' )
64
+ createdAt=$( echo " $i " | jq -r ' .createdAt' | date -u)
65
+ lastModifiedAt=$( echo " $i " | jq -r ' .lastModifiedAt' | date -u)
66
+ _credentialsLoaded=$( echo " $i " | jq -r ' .credentialsLoaded' )
67
+ scopes=$( echo " $i " | jq -r ' .scopes' )
68
+
69
+
70
+ if [ $_credentialsLoaded = true ]
71
+ then
72
+ credentialsLoaded=" ✅"
73
+ else
74
+ credentialsLoaded=" ❌"
75
+ fi
76
+
77
+ echo " <tr class=\" $highlightclass \" >" >> " $report_html "
78
+ echo " <td>$name </td>" >> " $report_html "
79
+ echo " <td>$status </td>" >> " $report_html "
80
+ echo " <td>$companyName </td>" >> " $report_html "
81
+ echo " <td>$appId </td>" >> " $report_html "
82
+ echo " <td>$appFamily </td>" >> " $report_html "
83
+ echo " <td>$callbackUrl </td>" >> " $report_html "
84
+ echo " <td>$accessType </td>" >> " $report_html "
85
+ echo " <td>$createdAt </td>" >> " $report_html "
86
+ echo " <td>$lastModifiedAt </td>" >> " $report_html "
87
+ echo " <td>$credentialsLoaded </td>" >> " $report_html "
88
+ echo " <td>$scopes </td>" >> " $report_html "
89
+ echo " </tr>" >> " $report_html "
90
+ done
91
+ fi
92
+
93
+ echo " </tbody></table></div>" >> " $report_html "
0 commit comments