Skip to content

Repository files navigation

a7 — CLI for API7 Enterprise Edition

a7 is a command-line tool for managing API7 Enterprise Edition API Gateway from your terminal. It wraps both the API7 EE control-plane API (/api/*) and the APISIX admin API (/apisix/admin/*) to provide convenient, scriptable access to gateway groups, routes, services, consumers, SSL certificates, plugins, and more.

Features

  • Resource CRUD — Create, list, get, update, and delete current API7 EE resource types:
    • Control Plane: Gateway Group
    • Runtime: Route, Service, Consumer, SSL Certificate, Plugin, Global Rule, Stream Route, Plugin Metadata, Credential, Secret, Proto
  • Context management — Switch between multiple API7 EE instances (a7 context create, a7 context use, a7 context list)
  • Gateway group scoping — All runtime operations are scoped to a gateway group via --gateway-group flag or context config
  • Rich output — Human-friendly tables in TTY, machine-readable JSON/YAML in pipes (--output json|yaml|table)
  • Shell completions — Bash, Zsh, Fish, PowerShell (a7 completion)

Installation

Using Go

If you have Go 1.22+ installed:

go install github.com/api7/a7/cmd/a7@latest

This installs the a7 binary to your $GOPATH/bin (or $HOME/go/bin by default). Make sure it's in your PATH.

Build from Source

git clone https://github.com/api7/a7.git
cd a7
make build
# Binary is at ./bin/a7

Quick Start

Prerequisites

  • a7 installed (see Installation above)
  • A running API7 Enterprise Edition instance with Admin API access
  • An API7 EE access token

1. Configure a context

# Create a context pointing to your API7 EE instance
a7 context create dev \
--server https://api7ee.example.com \
--token a7ee.your-access-token \
--gateway-group default
# Verify the active context
a7 context current
# List all contexts
a7 context list

2. Explore gateway groups

# List all gateway groups
a7 gateway-group list
# Get details of a specific gateway group
a7 gateway-group get <id> --output json

3. Create resources

# Create a service with inline upstream
a7 service create -g default -f service.yaml
# Create a route
a7 route create -g default -f route.yaml

4. Read and explore

# List all routes (table output in terminal)
a7 route list
# Get a specific route in JSON
a7 route get <id> --output json
# Get it in YAML
a7 route get <id> --output yaml
# List available plugins
a7 plugin list

5. Update a resource

# Update the route description
a7 route update <id> \
--name my-route \
--desc "Updated route for API v1"

6. Clean up

# Delete the route and service
a7 route delete <id> -g default --force
a7 service delete <id> -g default --force

Commands

Utility

CommandDescription
a7 versionPrint CLI version
a7 completion <shell>Generate shell completions (bash, zsh, fish, powershell)
a7 context createCreate a connection context
a7 context listList all contexts
a7 context use <name>Switch active context
a7 context currentShow current context
a7 context delete <name>Delete a context

Control Plane Resources

CommandAliasActionsDescription
a7 gateway-groupgglist, get, create, update, deleteManage gateway groups

Runtime Resources

CommandAliasActionsDescription
a7 routertlist, get, create, update, deleteManage routes
a7 servicesvclist, get, create, update, deleteManage runtime services
a7 consumerclist, get, create, update, deleteManage consumers
a7 ssllist, get, create, update, deleteManage SSL certificates
a7 pluginpllist, getManage plugins
a7 global-rulegrlist, get, create, update, deleteManage global rules
a7 stream-routesrlist, get, create, update, deleteManage stream routes
a7 plugin-metadatapmget, create, update, deleteManage plugin metadata
a7 credentialcredlist, get, create, update, deleteManage consumer credentials
a7 secretseclist, get, create, update, deleteManage secret providers
a7 protopblist, get, create, update, deleteManage protobuf definitions

Authentication

a7 supports API7 EE access tokens via the X-API-KEY header.

Precedence (highest to lowest):

  1. --token flag
  2. A7_TOKEN environment variable
  3. Context config (~/.config/a7/config.yaml)

Token Types

PrefixTypeScope
a7eeAccess TokenFull control-plane + admin API

Configuration

Config file: ~/.config/a7/config.yaml

current-context: devcontexts:
- name: devserver: https://api7ee.dev.example.comtoken: a7ee.xxxxxgateway-group: default
- name: prodserver: https://api7ee.prod.example.comtoken: a7ee.yyyyygateway-group: productiontls-skip-verify: falseca-cert: /path/to/ca.pem

Override the config directory with A7_CONFIG_DIR or XDG_CONFIG_HOME.

Environment Variables

VariableDescription
A7_TOKENAPI access token
A7_SERVERControl-plane server URL
A7_GATEWAY_GROUPDefault gateway group
A7_CONFIG_DIRConfig directory path
NO_COLORDisable color output

Global Flags

--server API7 EE server URL (overrides context)
--token API access token (overrides context)
--gateway-group Default gateway group (overrides context)
-o, --output Output format: json, yaml (default: table)

Requirements

  • Go 1.22+
  • API7 Enterprise Edition 3.x with Admin API enabled

Development

make build # Build binary to ./bin/a7
make test# Run unit tests
make test-verbose # Tests with verbose output
make lint # Run linter
make fmt # Format code
make vet # Run go vet
make check # fmt + vet + lint + test

See AGENTS.md for the full development guide, coding conventions, and how to add new commands.

Documentation

Contributing

Contributions are welcome. Please see AGENTS.md for development workflow and coding conventions.

License

Apache License 2.0

About

API7 API Gateway Enterprise Edition CLI

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages