Last active
          July 21, 2023 19:32 
        
      - 
      
 - 
        
Save SuriyaRuk/71dd1d7b5d568b8ab8a02367b4a2e046 to your computer and use it in GitHub Desktop.  
    counting object on kong
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| host=127.0.0.1 | |
| port=8001 | |
| for object in services routes plugins consumers certificates upstreams snis tags;do | |
| cout=$(curl -sL $host:$port/$object | jq .data | jq .[] | jq .id | wc -l) | |
| offset=$(curl -sL $host:$port/$object | grep -o '"offset":"[^"]*' | grep -o '[^"]*$'); | |
| while [ "$offset" != "" ];do | |
| cout=$(($cout + $(curl -sL $host:$port/$object?offset=$offset | jq .data | jq .[] | jq .id | wc -l))) | |
| offset=$(curl -sL $host:$port/$object?offset=$offset | grep -o '"offset":"[^"]*' | grep -o '[^"]*$') | |
| done | |
| echo $object=$cout | |
| cout=0 | |
| done | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment