CLI tools which is used to visualize Akamai Network list usage.
Under heavy development Please forgive us for some error or issue.
- Akamai Network List CLI - to get Network list data
 - Akamai AppSec CLI - to get Security configuration data
 - GraphViz - to generate images from 
.dotgraphs 
- Read Akamai Security configuration
 - List Akamai Security configurations
 - Read Akamai Network list
 - List Akamai Network lists
 
> export AKAMAI_EDGERC_SECTION="default"
> export AKAMAI_EDGERC_CONFIG="~/.edgerc"> export SOURCE_DIR="/tmp"
> akamai appsec configs --json --edgerc ${AKAMAI_EDGERC_CONFIG} --section ${AKAMAI_EDGERC_SECTION} | jq '[.configurations[] | {configId: .id, configName: .name}]' > ${SOURCE_DIR}/configurations_map.jsonfor CONFIGURATION in $(akamai appsec --edgerc ${AKAMAI_EDGERC_CONFIG} --section ${AKAMAI_EDGERC_SECTION} configs)
do
  akamai appsec --json --edgerc ${AKAMAI_EDGERC_CONFIG} --section ${AKAMAI_EDGERC_SECTION} export --config ${CONFIGURATION} | jq . > ${SOURCE_DIR}/${CONFIGURATION}.json
doneTo get one Network list usage graph
# Default output type is JSON. If destination flag is not set, result will be sent to STDOUT
> export OUTPUT="dot"
> export DESTINATION="~/myrepo/netlist-usage/"
> harvestgraph --id 12345_NETWORKLIST --name "Network List" -m ${SOURCE_DIR}/configurations_map.json -s ${SOURCE_DIR}/appsecConfigs -d ${DESTINATION} -o ${OUTPUT}To get all Network lists usage graphs
for NETLIST_ID in $(akamai netlist --config ${AKAMAI_EDGERC_CONFIG} --section ${AKAMAI_EDGERC_SECTION} get all | jq '.[].uniqueId' | tr -d '"')
do
  NETLIST_NAME=$(akamai netlist --config ${AKAMAI_EDGERC_CONFIG} --section ${AKAMAI_EDGERC_SECTION} get by-id --id ${NETLIST_ID} | jq '.name' | tr -d '"')
  ./harvestgraph --id 12345_NETWORKLIST --name "Network List" -m ${SOURCE_DIR}/configurations_map.json -s ${SOURCE_DIR}/appsecConfigs -d ${DESTINATION} -o ${OUTPUT}
doneBash script for actions below can be found in this repository: run.sh
> mkdir ${DESTINATION}/images
> ls -1 ${DESTINATION} | grep '.dot' | tr -d '.dot' | xargs -I % sh -c "dot -Tpng graphs/%.dot > ${DESTINATION}/images/%.png"> ls -1 ${DESTINATION}/images | tr -d '.png' | xargs -I % sh -c "echo -e $'List ID: __%__\n\n\\n' >> Network_Lists_Dependencies.md"
> sed -i 's/\\\!\[/![/g' Network_Lists_Dependencies.mdMetadata json file can be found in example/example.metadata file.
Graph
> ./harvestgraph --help
NAME:
   harvestgraph - CLI tools which used to visualize Akamai Network list usage.
USAGE:
   harvestgraph [global options] command [command options] [arguments...]
VERSION:
   local
AUTHORS:
   Petr Artamonov
   Rafal Pieniazek
COMMANDS:
     help, h  Shows a list of commands or help for one command
GLOBAL OPTIONS:
   --destination value, -d value                                 Path for destination files. If empty results will be sent to STDOUT
   --id ID, -i ID                                                Network List ID
   --map-file configuration map file, -m configuration map file  Path for configuration map file
   --name NAME, -n NAME                                          Network List NAME
   --output value, -o value                                      Output result as .json metadata or as .dot graphviz files (default: "json")
   --source value, -s value                                      Path, where Security configuration JSON files are located (default: "os.TempDir()")
   --help, -h                                                    show help
   --version, -v                                                 print the versionDocker images is based on Alpine distribution and it has all required CLI/tools to generate dependency graphs.
- Akamai CLI
 - Akamai AppSec CLI
 - Akamai Netlist CLI
 - graphviz CLIs (dot we need to have)
 - harvestgraph binary
 
> docker build --build-arg harvestgraph_version=${VERSION} . -t docker.pkg.github.com/apiheat/harvestgraph/harvestgraph:${VERSION}docker run -it -e "AKAMAI_EDGERC_SECTION=default" -v $HOME/.edgerc:/root/.edgerc -v $HOME/project/path:/some_path --rm docker.pkg.github.com/apiheat/harvestgraph/harvestgraph:${VERSION}In order to develop the tool with us do the following:
- 
Fork repository
 - 
Clone it to your folder ( within GO path )
 - 
Ensure you can restore dependencies by running
go get ./...
 - 
Make necessary changes
 - 
Make sure solution builds properly ( feel free to add tests )
> go build -ldflags="-s -w -X main.appVer=1.2.3 -X main.appName=$(basename `pwd`)" -o $(basename `pwd`)
 

