Open gautam-y opened 8 months ago
fi_org_list="${reports_dir}/org_list_all.csv" rm $fi_org_list echo "Organization, Id" >> $fi_org_list echo "Creating list of all Organizations in file $fi_org_list..."
all_orgs_json=$(curl -X GET -H "Authorization: Bearer " -H "Content-Type: application/json" -k "/organizations/" -d "format=json")
all_org_names=$(echo $all_orgs_json | jq '.results[].name' | tr -d '"') all_org_ids=$(echo $all_orgs_json | jq '.results[].id')
paste -d ',' <(echo -e "$all_org_names") <(echo -e "$all_org_ids") >> $fi_org_list
Get list of all Org ids and names into their respective array variables
fi_org_list="${reports_dir}/org_list_all.csv" rm $fi_org_list echo "Organization, Id" >> $fi_org_list echo "Creating list of all Organizations in file $fi_org_list..."
Make a request to the Tower API using curl
all_orgs_json=$(curl -X GET -H "Authorization: Bearer" -H "Content-Type: application/json" -k "/organizations/" -d "format=json")
Extract organization names and ids from the JSON response using jq
all_org_names=$(echo $all_orgs_json | jq '.results[].name' | tr -d '"') all_org_ids=$(echo $all_orgs_json | jq '.results[].id')
Combine the names and ids into a CSV file
paste -d ',' <(echo -e "$all_org_names") <(echo -e "$all_org_ids") >> $fi_org_list