Akamai Command-Line Interface
repository·master·Indexed 42 days ago
https://github.com/akamai/cliA command-line tool used to configure and manage Akamai's platform and products. It features a task-oriented interface and an extensible package system supporting Go, Python, and JavaScript. The CLI supports EdgeGrid authentication via .edgerc files and provides built-in commands for package management, configuration, and shell auto-completion for Bash and Zsh.
What's inside Akamai CLI
- The Akamai command-line interface (CLI) allows you to configure Akamai's platform and products directly from your terminal. It features a consistent, task-oriented interface across all Akamai products. You can extend its functionality by installing ready-to-use product packages or building your own custom solutions using supported languages like Go, Python, and JavaScript.
How to build custom Akamai CLI commands
masterYou can build custom commands using any language (Python, Go, JavaScript, etc.). To ensure compatibility with the Akamai CLI framework, follow these requirements:
- Naming: The executable must be named
akamai-<command>(dashed-lowercase) orakamai<Command>(camelCase). - Help: The command must support
akamai-<command> helpand ideallyakamai-<command> help <sub-command>. - Authentication: If using Akamai APIs, the executable must support the
.edgercformat and respect the--edgercand--sectionflags. - Error Handling: The executable must exit with a non-zero status code if an action fails.
- Distribution: The package must be available via a Git repository that supports standard SSH public key authentication.
- Naming: The executable must be named
Install the Akamai CLI with Docker
masterYou can use a Docker container that comes with the Akamai CLI and pre-installed public packages. This is useful for a consistent development environment.
Run the Akamai Development Environment
To run the container and mount your local
.edgercfile (required for authentication) into the container, use the following command:docker run -it -v $HOME/.edgerc:/root/.edgerc:ro akamai/shellPersistent Configuration
To use a local
.akamai-clidirectory to manage your installed packages and persist configuration, modify the volume mount:docker run -it -v $HOME/.akamai-cli:/cli/.akamai-cli akamai/shellShell Alias
To use the
akamaicommand directly via Docker, add this alias to your.bashrc,.bash_profile, or.zshrc:alias akamai='docker run -it -v $HOME/.edgerc:/root/.edgerc:ro akamai/shell'# Run with local .edgerc mounted $ docker run -it -v $HOME/.edgerc:/root/.edgerc:ro akamai/shell # Run with local .akamai-cli for persistent packages $ docker run -it -v $HOME/.akamai-cli:/cli/.akamai-cli akamai/shell # Add to shell config for convenience alias akamai='docker run -it -v $HOME/.edgerc:/root/.edgerc:ro akamai/shell'Install the Akamai CLI with Homebrew
masterIf you have Homebrew installed on your system, you can install the Akamai CLI and its necessary dependencies using a single command. This will compile and globally install the binary.
$ brew install akamaiCompile the Akamai CLI from source
masterTo build the Akamai CLI from source, you must have Go 1.25.7 or later installed.
- Navigate to your
$GOPATH. - Clone the repository:
git clone github.com/akamai/cli. - Enter the
clidirectory. - Run the
go buildcommand for your specific platform. - Move the resulting binary to a directory in your
$PATH.
# 1. Change directory $ cd $GOPATH # 2. Fetch package $ git clone github.com/akamai/cli # 3. Go to package directory $ cd cli # 4. Compile binary # Linux, macOS, or other Unix-based systems: $ go build -o akamai cli/main.go # Windows: $ go build -o akamai.exe cli/main.go- Navigate to your
Authenticate Akamai CLI with EdgeGrid credentials
masterAkamai-branded packages use a
.edgercfile for standard EdgeGrid authentication. By default, the CLI looks for this file in your$HOMEdirectory under a[default]section.To use a different file or section, use the
--edgerc(or-e) and--section(or-s) global flags.Example
.edgercformat:[default] client_secret = C113nt53KR3TN6N90yVuAgICxIRwsObLi0E67/N8eRN= host = akab-h05tnam3wl42son7nktnlnnx-kbob3i3v.luna.akamaiapis.net access_token = akab-acc35t0k3nodujqunph3w7hzp7-gtm6ij client_token = akab-c113ntt0k3n4qtari252bfxxbsl-yvsdjakamai --edgerc "~/.edgerc" --section "default" property-manager listConfigure logging levels for Akamai CLI
masterYou can view detailed log information by prepending the
AKAMAI_LOGenvironment variable to any command. The available levels are (from least to most verbose):fatalerrorwarninfodebug
To redirect logs to a specific file, set the
AKAMAI_CLI_LOG_PATHenvironment variable.Example: Running a command with debug logging to a file:
AKAMAI_LOG=debug AKAMAI_CLI_LOG_PATH=akamai.log akamai update property-managerAKAMAI_LOG=debug akamai update property-managerInstall the Akamai CLI via binaries
masterDownload a release binary compatible with your operating system from the official releases page.
Linux and macOS
After downloading, make the binary executable and move it to a directory in your
$PATH(e.g.,/usr/local/bin/).Windows
Download the appropriate
.exeand run it directly from the command line.# Linux and macOS $ chmod +x ~/Downloads/akamai-<VERSION>-<PLATFORM> $ mv ~/Downloads/akamai-<VERSION>-<PLATFORM> /usr/local/bin/akamai # Windows $ akamai.exe helpManage Akamai CLI configuration
masterThe
configcommand allows you to interact with the Akamai CLI configuration settings. You can retrieve, set, unset, or list configuration values using a dot-notation path in the format<section>.<key>.Configuration Path Format
All commands that target a specific setting require the path to be provided as the first argument in the format:
section.keyIf a key contains hyphens in the actual configuration, the parser handles the mapping from the dot-notation provided in the CLI.
The structure of an Akamai CLI package (cli.json)
masterAkamai CLI packages are defined by a
cli.jsonfile located within a package directory. This file describes the available subcommands, their requirements, and how to obtain the necessary binaries. When developing or inspecting a package, thesubcommandsstructure is the core data model used by the CLI to register and execute commands.Key fields in the package definition include:
commands: A map of command objects containing metadata likename,bin(for binary-based packages), and other command-specific properties.requirements: Apackages.LanguageRequirementsobject specifying what the package needs to run (e.g., specific language runtimes).pkg: The name of the package (derived from the directory name).
Note: Command names are automatically converted to lowercase by the CLI during processing.
Define command package metadata with cli.json
masterEvery Akamai CLI package requires a
cli.jsonfile to define its requirements and commands. This file allows the CLI to manage dependencies and locate binaries.Schema Overview:
requirements: Specifies runtime requirements (e.g.,go,node,python) and version constraints.commands: An array of command objects containing:name: The command name (used for the executable).aliases: Array of alternative names.version: Command version.description: Short summary.bin: A URL for fetching binaries. Supports placeholders:{{.Version}},{{.Name}},{{.OS}}(windows, mac, linux),{{.Arch}}(386, amd64, arm64), and{{.BinSuffix}}(e.g.,.exe).
{ "requirements": { "go": "1.8.0" }, "commands": [ { "name": "purge", "version": "0.1.0", "description": "Purge content from the Edge", "bin": "https://github.com/akamai/cli-purge/releases/download/{{.Version}}/akamai-{{.Name}}-{{.OS}}{{.Arch}}{{.BinSuffix}}" } ] }How binary-based commands are downloaded
masterFor packages that provide pre-compiled binaries rather than source code, the Akamai CLI uses a template-based URL system to fetch the correct executable for the user's environment.
When a command is identified as a binary command (i.e., it has a
binfield defined), the CLI performs the following:- Determines OS/Arch: It detects the current
runtime.GOOSandruntime.GOARCH.- Note:
darwinis mapped tomacfor URL purposes. - Note:
windowstargets receive a.exesuffix.
- Note:
- Resolves URL: It parses the
bintemplate string from thecli.jsonusing the command's metadata. - Downloads and Installs: It downloads the binary, saves it as
akamai-<command-name><suffix>, and sets the file permissions to0775(executable).
Example of how a binary URL might be templated in a
cli.json(conceptual):https://example.com/binaries/{{.Name}}-{{.OS}}-{{.Arch}}- Determines OS/Arch: It detects the current