Skip to content

api7/adc

Repository files navigation

API Declarative CLI (ADC)

ADC is a command line utility that interfaces with API7 Enterprise and Apache APISIX Admin APIs.

Supported Backends

The following backend types are supported in ADC:

  1. API7 Enterprise
  2. Apache APISIX

Supported Converters

The following converters are supported to convert API specifications to ADC configuration:

  1. OpenAPI Spec 3

Installation

The easiest way to install ADC is through the install script:

curl -sL "https://run.api7.ai/adc/install" | sh

Or, you can download the appropriate binary from the releases page:

wget https://github.com/api7/adc/releases/download/v0.12.0/adc_0.12.0_linux_amd64.tar.gz
tar -zxvf adc_0.12.0_linux_amd64.tar.gz
mv adc /usr/local/bin/adc

Pre-built binaries for amd64 and arm64 on Linux, Windows, and macOS are available now.

Configure ADC

You can configure ADC through environment variables or command line flags. Run adc help [command] to see the available configuration options for a command.

ADC supports dotenv, so you can store and use your environment variables in a .env file. The examples below show how to configure ADC for both API7 Enterprise and Apache APISIX backends.

Example API7 Enterprise Configuration

ADC_BACKEND=api7ee
ADC_SERVER=https://localhost:7443
ADC_TOKEN=<token generated from the dashboard>

Example Apache APISIX Configuration

ADC_SERVER=http://localhost:9180
ADC_TOKEN=<APISIX Admin API key>

Usage

This section highlights some of the common ADC commands.

Check Connectivity

The ping command verifies the configuration by trying to connect to the configured backend:

adc ping

Dump Configuration in ADC Format

The dump command fetches the current configuration of the backend and saves it in the ADC configuration file format:

adc dump -o adc.yaml

Show the Difference between Local and Remote Configuration

The diff command compares the configuration in the specified ADC configuration file with the current configuration of the backend:

adc diff -f adc.yaml

Synchronize Local Configuration

The sync command synchronizes the configuration in the specified ADC configuration file with the backend:

adc sync -f adc.yaml

Convert API Specifications

The convert command converts API specifications to ADC configuration. Currently, it supports converting an OpenAPI 3 specification to ADC configuration.

adc convert openapi -f openapi.yaml

Verify ADC Configuration

The lint command verifies the provided ADC configuration file locally.

adc lint -f adc.yaml

Development

To build ADC from source, install Nx and run:

pnpm install
nx build cli

To use the binary, run:

node dist/apps/cli/main.js -h

License

This project is licensed under the Apache 2.0 License.