Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions .kokoro/nightly/get-apiary-service-names.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ output_filename="../../libraries-release-data/artifacts_to_services_apiary.txt"
sudo apt-get update
sudo apt-get install -q -y jq

total_files_processed=0
successful_outputs=0
# loop through dicovery json files
for file in *.json; do
((total_files_processed++))
# Use jq to extract the "name" field

# group_id logic: https://github.com/googleapis/google-api-java-client-services/blob/421c5d6ed56d5eb1257d3fc057d7d6b4fd2f9bb7/generator/src/googleapis/codegen/utilities/maven_utils.py#L50
Expand All @@ -30,21 +33,37 @@ for file in *.json; do
default_host=$(jq -r '.rootUrl' "$file")
owner_domain=$(jq -r '.ownerDomain' "$file")

if [[ "$default_host" =~ ^https:// ]] && [ -n "$artifact_id_suffix" ] && [ -n "$owner_domain" ]; then
if [[ "$owner_domain" != 'google.com' ]]; then
echo "$owner_domain =============="
# Check if jq failed to extract essential fields
if [ -z "$artifact_id_suffix" ] || [ -z "$default_host" ] || [ -z "$owner_domain" ]; then
echo "Error: Could not extract 'name', 'rootUrl', or 'ownerDomain' from $file. Skipping."
continue
fi
if [[ "$owner_domain" != 'google.com' ]]; then
echo "Info: '$owner_domain' in $file is not 'google.com'. Skipping."
continue
fi
group_id="com.google.apis"
if [[ "$default_host" == "https://www.googleapis.com/" ]]; then
echo "rootUrl is https://www.googleapis.com/, use name ${service_name} as service_name"
service_name="$artifact_id_suffix"
else
service_name_parts=$(echo "$default_host" | cut -d'/' -f3 | cut -d'.' -f1 2>/dev/null)
if [ -z "$service_name_parts" ]; then
echo "Error: Could not extract 'service_name' from 'rootUrl' ('$default_host') in $file. Skipping."
continue
fi
group_id="com.google.apis"
service_name=$(echo "$default_host" | cut -d'/' -f3 | cut -d'.' -f1)
artifact_id="google-api-services-${artifact_id_suffix}"
echo "${group_id},${artifact_id},${service_name}" >> "$output_filename"
else
echo "$default_host: Not a valid URL or No 'name' field found in $file"
service_name="$service_name_parts"
fi
artifact_id="google-api-services-${artifact_id_suffix}"
echo "${group_id},${artifact_id},${service_name}" >> "$output_filename"
((successful_outputs++))

done

echo "Processing complete."
echo "Total files processed: $total_files_processed"
echo "Successful outputs recorded: $successful_outputs"

cd ../..

rm -rf discovery-artifact-manager/
Loading