I'd read the API documentation and the jq documentation. Yes, it is a bit tricky for a beginner like me but it gets easier with use.
This should get you started with what you need...
DAYS=20
DOMAIN="MGMT"
TMPDIR="/var/log/expiring"
STARTH=$(date +%m/%d/%Y )
echo Starting now: $STARTH
START=$(date -d "$STARTH" +%s%N | cut -b1-13)
ENDH=$(date +%m/%d/%Y -d '+'$DAYS' days')
echo Ending $ENDH
END=$(date -d "$ENDH" +%s%N | cut -b1-13)
TOFILE=$TMPDIR/time-object-name.txt
REFILE=$TMPDIR/rules_expiring.txt
ORFILE=$TMPDIR/old_rules.txt
PFILE=$TMPDIR/policies.tmp
printf "\nSearching for Rules that are within $DAYS days of expiring in $DOMAIN.\n"
mgmt_cli -r true -d $DOMAIN show times details-level full limit 500 --format json | jq --arg START ${START} --arg END ${END} --raw-output '.objects[] | select( (.end.posix|tonumber) >= ($START|tonumber) and (.end.posix|tonumber) <= ($END|tonumber) ) | .name ' > $TOFILE
mgmt_cli -r true -d $DOMAIN show access-layers limit 500 --format json | jq --raw-output '."access-layers"[] | (.name)' | grep "\ Security" > $PFILE
OFS=$IFS
IFS=$'\n'
for POL_NAME in $(cat $PFILE); do
IFS=$OFS
echo "Search policies for the expiring time objects.."
for line in $(cat $TOFILE);
do
echo "Searching for time object $line in the $POL_NAME"
f_log "Searching for time object $line in the $POL_NAME" $LOGFILE
mgmt_cli -r true -d $DOMAIN show access-rulebase limit 500 name "$POL_NAME" details-level "standard" use-object-dictionary true filter "$line" --format json | jq --raw-output '.rulebase[] .rulebase[] | ."rule-number"' > $ORFILE
done
for rule_num in $(cat $ORFILE ) ;
do
echo "Expiring Rules on $DOMAIN $POL_NAME:"
mgmt_cli -r true -d $DOMAIN show access-rule layer "$POL_NAME" rule-number "$rule_num" --format json |jq --raw-output --arg PN "$POL_NAME" --arg RN "$rule_num" '($PN + "," + $RN + "," + .source[].name + "," + .destination[].name + "," + .service[].name + "," + .action.name + "," + .time[].name + "," + .comments)' >> $REFILE
done
done
cat $REFILE