Skip to content

Commit 0f776f6

Browse files
authored
Merge pull request #637 from SamPriyadarshi/report-unsupported-apis
feat: added apis that are unsupported in x/hybrid to sackmesser report
2 parents 1813c62 + 130e19f commit 0f776f6

File tree

5 files changed

+267
-0
lines changed

5 files changed

+267
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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>Companies</h3>" >> "$report_html"
18+
19+
mkdir -p "$export_folder/$organization/config/resources/edge/env/$environment/company"
20+
21+
sackmesser list "organizations/$organization/companies"| jq -r -c '.[]|.' | while read -r companyname; do
22+
sackmesser list "organizations/$organization/companies/$(urlencode "$companyname")" > "$export_folder/$organization/config/resources/edge/env/$environment/company/$(urlencode "$companyname")".json
23+
done
24+
25+
if ls "$export_folder/$organization/config/resources/edge/env/$environment/company"/*.json 1> /dev/null 2>&1; then
26+
jq -n '[inputs]' "$export_folder/$organization/config/resources/edge/env/$environment/company"/*.json > "$export_folder/$organization/config/resources/edge/env/$environment/companies".json
27+
fi
28+
29+
echo "<div><table id=\"company-lint\" data-toggle=\"table\" class=\"table\">" >> "$report_html"
30+
echo "<thead class=\"thead-dark\"><tr>" >> "$report_html"
31+
echo "<th data-sortable=\"true\" data-field=\"id\">Name</th>" >> "$report_html"
32+
echo "<th data-sortable=\"true\" data-field=\"name\">Display Name</th>" >> "$report_html"
33+
echo "<th data-sortable=\"true\" data-field=\"status\">Status</th>" >> "$report_html"
34+
echo "<th data-sortable=\"true\" data-field=\"apps\">Apps</th>" >> "$report_html"
35+
echo "</tr></thead>" >> "$report_html"
36+
37+
echo "<tbody class=\"mdc-data-table__content\">" >> "$report_html"
38+
39+
if [ -f "$export_folder/$organization/config/resources/edge/env/$environment/companies".json ]; then
40+
jq -c '.[]' "$export_folder/$organization/config/resources/edge/env/$environment/companies".json | while read i; do
41+
name=$(echo "$i" | jq -r '.name')
42+
displayName=$(echo "$i" | jq -r '.displayName')
43+
_status=$(echo "$i" | jq -r '.status')
44+
apps=$(echo "$i" | jq -r '.apps[]?')
45+
46+
if [ $_status = "active" ]
47+
then
48+
status=""
49+
else
50+
status=""
51+
fi
52+
53+
echo "<tr class=\"$highlightclass\">" >> "$report_html"
54+
echo "<td>$name</td>" >> "$report_html"
55+
echo "<td>"$displayName"</td>" >> "$report_html"
56+
echo "<td>$status</td>" >> "$report_html"
57+
echo "<td>$apps</td>" >> "$report_html"
58+
echo "</tr>" >> "$report_html"
59+
done
60+
fi
61+
62+
echo "</tbody></table></div>" >> "$report_html"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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>LDAP Resources</h3>" >> "$report_html"
18+
19+
mkdir -p "$export_folder/$organization/config/resources/edge/env/$environment/ldapresource"
20+
21+
sackmesser list "organizations/$organization/environments/$environment/ldapresources"| jq -r -c '.[]|.' | while read -r ldapresourcename; do
22+
sackmesser list "organizations/$organization/environments/$environment/ldapresources/$(urlencode "$ldapresourcename")" > "$export_folder/$organization/config/resources/edge/env/$environment/ldapresource/$(urlencode "$ldapresourcename")".json
23+
done
24+
25+
if ls "$export_folder/$organization/config/resources/edge/env/$environment/ldapresource"/*.json 1> /dev/null 2>&1; then
26+
jq -n '[inputs]' "$export_folder/$organization/config/resources/edge/env/$environment/ldapresource"/*.json > "$export_folder/$organization/config/resources/edge/env/$environment/ldapresources".json
27+
fi
28+
29+
echo "<div><table id=\"ldapresource-lint\" data-toggle=\"table\" class=\"table\">" >> "$report_html"
30+
echo "<thead class=\"thead-dark\"><tr>" >> "$report_html"
31+
echo "<th data-sortable=\"true\" data-field=\"id\">Name</th>" >> "$report_html"
32+
echo "<th data-sortable=\"true\" data-field=\"admin\">Admin</th>" >> "$report_html"
33+
echo "<th data-sortable=\"true\" data-field=\"connectPool\">Connect Pool</th>" >> "$report_html"
34+
echo "<th data-sortable=\"true\" data-field=\"connection\">connection</th>" >> "$report_html"
35+
echo "</tr></thead>" >> "$report_html"
36+
37+
echo "<tbody class=\"mdc-data-table__content\">" >> "$report_html"
38+
39+
if [ -f "$export_folder/$organization/config/resources/edge/env/$environment/ldapresources".json ]; then
40+
jq -c '.[]' "$export_folder/$organization/config/resources/edge/env/$environment/ldapresources".json | while read i; do
41+
name=$(echo "$i" | jq -r '.name')
42+
admin=$(echo "$i" | jq -r '.admin' | jq -r 'keys[] as $k | "<li>\($k): \(.[$k] | .)</li>"')
43+
connectPool=$(echo "$i" | jq -r '.connectPool' | jq -r 'keys[] as $k | "<li>\($k): \(.[$k] | .)</li>"')
44+
connection=$(echo "$i" | jq -r '.connection' | jq -r 'keys[] as $k | "<li>\($k): \(.[$k] | .)</li>"')
45+
46+
echo "<tr class=\"$highlightclass\">" >> "$report_html"
47+
echo "<td>$name</td>" >> "$report_html"
48+
echo "<td><ul>$admin</ul></td>" >> "$report_html"
49+
echo "<td><ul>$connectPool</ul></td>" >> "$report_html"
50+
echo "<td><ul>$connection</ul></td>" >> "$report_html"
51+
echo "</tr>" >> "$report_html"
52+
done
53+
fi
54+
55+
echo "</tbody></table></div>" >> "$report_html"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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>Users</h3>" >> "$report_html"
18+
19+
mkdir -p "$export_folder/$organization/config/resources/edge/env/$environment/user"
20+
21+
sackmesser list "users"| jq -r -c '.[]|.[]' | while read -r userdetail; do
22+
email=$(echo "$userdetail" | jq -r '.name')
23+
sackmesser list "users/$email" > "$export_folder/$organization/config/resources/edge/env/$environment/user/$email".json
24+
done
25+
26+
if ls "$export_folder/$organization/config/resources/edge/env/$environment/user"/*.json 1> /dev/null 2>&1; then
27+
jq -n '[inputs]' "$export_folder/$organization/config/resources/edge/env/$environment/user"/*.json > "$export_folder/$organization/config/resources/edge/env/$environment/users".json
28+
fi
29+
30+
echo "<div><table id=\"user-lint\" data-toggle=\"table\" class=\"table\">" >> "$report_html"
31+
echo "<thead class=\"thead-dark\"><tr>" >> "$report_html"
32+
echo "<th data-sortable=\"true\" data-field=\"id\">Email</th>" >> "$report_html"
33+
echo "<th data-sortable=\"true\" data-field=\"firstname\">First Name</th>" >> "$report_html"
34+
echo "<th data-sortable=\"true\" data-field=\"lastname\">Last Name</th>" >> "$report_html"
35+
echo "</tr></thead>" >> "$report_html"
36+
37+
echo "<tbody class=\"mdc-data-table__content\">" >> "$report_html"
38+
39+
if [ -f "$export_folder/$organization/config/resources/edge/env/$environment/users".json ]; then
40+
jq -c '.[]' "$export_folder/$organization/config/resources/edge/env/$environment/users".json | while read i; do
41+
emailId=$(echo "$i" | jq -r '.emailId')
42+
firstName=$(echo "$i" | jq -r '.firstName')
43+
lastName=$(echo "$i" | jq -r '.lastName')
44+
45+
echo "<tr class=\"$highlightclass\">" >> "$report_html"
46+
echo "<td>$emailId</td>" >> "$report_html"
47+
echo "<td>$firstName</td>" >> "$report_html"
48+
echo "<td>$lastName</td>" >> "$report_html"
49+
echo "</tr>" >> "$report_html"
50+
done
51+
fi
52+
53+
echo "</tbody></table></div>" >> "$report_html"

tools/apigee-sackmesser/cmd/report/report.sh

+4
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ source $helper_dir/references.sh
429429

430430
if [ "$opdk" == "T" ]; then
431431
source $helper_dir/virtualhosts.sh
432+
source $helper_dir/companies.sh
433+
source $helper_dir/companyapps.sh
434+
source $helper_dir/ldapresources.sh
435+
source $helper_dir/users.sh
432436
fi
433437

434438
echo "<h2>Organization Configurations</h2>" >> "$report_html"

0 commit comments

Comments
 (0)