Managing Apicurio Registry content using the command-line interface
You can use the Apicurio Registry command-line interface (CLI) to manage Apicurio Registry content from the command line. The CLI provides commands for managing CLI contexts, authentication, groups, artifacts, artifact versions, rules, role mappings, and export and import of registry data.
|
The CLI is currently in dev-preview status and is unstable; its arguments and behavior are subject to backwards-incompatible changes. The CLI supports Linux (x86_64, bash), macOS (Apple Silicon, zsh), and Windows (x86_64, command prompt or PowerShell). |
Prerequisites
-
You have installed Apicurio Registry.
-
You have access to a bash shell on Linux (x86_64), a zsh shell on macOS (Apple Silicon), or a command prompt or PowerShell on Windows (x86_64).
Installing the Apicurio Registry CLI
You can install the Apicurio Registry CLI to interact with Apicurio Registry from the command line. The CLI is distributed as a native executable in a platform-specific .zip file, so it does not require a Java runtime.
-
You have a Linux x86_64 system with a bash shell, a macOS Apple Silicon system with a zsh shell, or a Windows x86_64 system with a command prompt or PowerShell.
-
Download the .zip file for your platform, for example
apicurio-registry-cli-VERSION-linux-x86_64.zip(Linux),apicurio-registry-cli-VERSION-osx-aarch64.zip(macOS), orapicurio-registry-cli-VERSION-windows-x86_64.zip(Windows), from the Apicurio Registry GitHub Releases page. Alternatively, you can download the CLI from the Maven Central repository by searching forapicurio-registry-cli. -
Extract the downloaded file to a location of your choice:
On Linux and macOS:
$ unzip apicurio-registry-cli-VERSION-linux-x86_64.zip -d ~/apicurio-cliOn Windows:
> mkdir %USERPROFILE%\apicurio-cli > tar -xf apicurio-registry-cli-VERSION-windows-x86_64.zip -C %USERPROFILE%\apicurio-cli -
Install the CLI for the current user:
On Linux and macOS:
$ cd ~/apicurio-cli $ ./acr installOn Windows:
> cd %USERPROFILE%\apicurio-cli > acr.cmd installThis command copies the CLI files to
$HOME/.apicurio/apicurio-registry-cli, creates symbolic links in$HOME/bin, updates your~/.bashrcfile (Linux) or~/.zshrcfile (macOS), and configures shell completions.On Windows, the CLI files are copied to
%USERPROFILE%\.apicurio\apicurio-registry-cliand the launcher is copied to%USERPROFILE%\bin, because creating a symbolic link there requires Developer Mode or an elevated prompt. Windows has no shell configuration file to source, so the command sets theACR_HOMEuser environment variable and adds thebindirectory to your userPathinstead. Shell completions are generated for bash and zsh only. -
Reload your shell configuration:
On Linux:
$ source ~/.bashrcOn macOS:
$ source ~/.zshrcOn Windows, open a new command prompt or PowerShell window so that it picks up the updated environment variables. The installed command is
acr, which the command prompt resolves toacr.cmdthroughPATHEXT. -
Verify the installation:
$ acr --helpTo update an installed CLI to a newer version, use the
acr updatecommand. The CLI checks for updates once per day. To disable the update check, runacr config set update.check-enabled=false.
Configuring Apicurio Registry CLI contexts
An Apicurio Registry CLI context stores the registry URL, optional default group and artifact identifiers, and authentication settings for one Apicurio Registry instance. You can create many contexts and switch between them as needed, similar to how you use contexts in Kubernetes.
-
Create a new context for your Apicurio Registry instance:
$ acr context create CONTEXT_NAME REGISTRY_URLFor example:
$ acr context create dev http://localhost:8080The CLI automatically switches to the newly created context.
Optional: Set default group and artifact identifiers for the context by using the
--group(-g) and--artifact(-a) options. Commands that accept these identifiers use the context defaults when you omit the corresponding option. -
List all configured contexts:
$ acr contextExample outputCurrent context is 'dev'. ID Registry URL Group ID Artifact ID ---- --------------------- ---------- ----------- dev* http://localhost:8080 my-schemasThe asterisk (*) indicates the current active context.
-
Optional: Create additional contexts without switching to them:
$ acr context create prod http://registry.example.com --no-switch-current -
Switch to a different context:
$ acr context use CONTEXT_NAME -
Update an existing context. If you omit the context name, the CLI updates the current context:
$ acr context update prod --registry-url http://registry.internal.example.com $ acr context update --group my-schemas -
Delete a context that you no longer need:
$ acr context delete CONTEXT_NAMEOptional: To delete all contexts, use the
--alloption.
Authenticating the Apicurio Registry CLI
You can log in to the Apicurio Registry instance of your current CLI context by using basic authentication or OAuth2 client credentials. The CLI stores secrets in the operating system keychain, and stores non-secret authentication settings in the context.
-
You have configured a CLI context for a Apicurio Registry instance that requires authentication.
-
On Linux, the
secret-toolutility (libsecret) is available for keychain storage. On macOS, the CLI uses the built-in keychain. On Windows, the CLI uses the built-in Credential Manager, which stores a secret of up to 2560 bytes.
-
To log in with basic authentication, provide a user name. The CLI prompts for the password:
$ acr login --username my-userAlternatively, provide the password with the
--password(-p) option. -
To log in with OAuth2 client credentials, provide the token endpoint and client ID. The CLI prompts for the client secret:
$ acr login --token-endpoint https://auth.example.com/realms/registry/protocol/openid-connect/token --client-id registry-clientOptional: Provide an OAuth2 scope with the
--scopeoption. -
Optional: On systems without a keychain, for example in headless environments, use the
--allow-unsafe-credential-storageoption. The CLI stores secrets in acredentials.jsonfile and prints a warning. The file is restricted to its owner, by0600permissions on Linux and macOS and by an owner-only access control list on Windows. This preference persists per context. -
To log out of the current context, run the following command. The CLI removes the stored secrets and clears the authentication settings of the context:
$ acr logoutAuthentication is configured per context. Secret values are stored in the operating system keychain or in the
credentials.jsonfile, never in theconfig.jsonconfiguration file.
Managing groups using the CLI
You can use the CLI to create, list, update, and delete artifact groups in Apicurio Registry. Groups offer a way to organize related artifacts.
-
You have configured at least one CLI context.
-
List all groups in the registry:
$ acr groupOptional: Use pagination options for large result sets:
$ acr group --page 1 --size 50 -
Create a new group:
$ acr group create GROUP_IDOptional: Include a description and labels:
$ acr group create my-schemas --description "Production schemas" --label env=prod --label team=platformThe group ID
defaultis reserved. You cannot create or update thedefaultgroup. -
Get details for a specific group:
$ acr group get GROUP_IDFor example:
$ acr group get my-schemas -
Update a group description:
$ acr group update my-schemas --description "Updated description"Optional: Add or update labels:
$ acr group update my-schemas --set-label env=staging --set-label owner=aliceOptional: Delete labels:
$ acr group update my-schemas --delete-label env -
Delete a group:
$ acr group delete GROUP_IDYou must configure Apicurio Registry with
apicurio.rest.deletion.group.enabled=trueto allow group deletions.Optional: To delete a group that has artifacts, use the
--forceoption:$ acr group delete my-schemas --forceUsing
--forcedeletes the group and all artifacts it contains. Use this option with caution.
Managing artifacts using the CLI
You can use the CLI to create, list, get, update, and delete artifacts in Apicurio Registry. When you omit the group option, the CLI uses the default group of the current context, or the default group.
-
You have configured at least one CLI context.
-
List the artifacts in a group:
$ acr artifact --group my-schemas -
Create a new artifact from a file:
$ acr artifact create my-artifact --group my-schemas --type AVRO --file schema.avscThe
--typeoption accepts the following values:AVRO,PROTOBUF,JSON,OPENAPI,ASYNCAPI,GRAPHQL,KCONNECT,WSDL,XSD, andXML. To read content from standard input, use--file -.Optional: Provide metadata with the
--name,--description, and--labeloptions, and set the identifier of the first version with the--versionoption. -
Get the metadata of an artifact:
$ acr artifact get my-artifact --group my-schemasTo retrieve the content of the latest version instead of the metadata, use the
--content(-c) option. The--contentand--output-typeoptions are mutually exclusive. -
Update the metadata of an artifact:
$ acr artifact update my-artifact --group my-schemas --description "Order event schema"Optional: Manage labels with the
--set-labeland--delete-labeloptions. -
Delete an artifact:
$ acr artifact delete my-artifact --group my-schemasYou must configure Apicurio Registry with
apicurio.rest.deletion.artifact.enabled=trueto allow artifact deletions.
Managing artifact versions using the CLI
You can use the CLI to list, create, get, update, and delete the versions of an artifact, including draft versions. When you omit the artifact option, the CLI uses the default artifact of the current context.
-
You have configured at least one CLI context.
-
The artifact exists in the registry.
-
List the versions of an artifact:
$ acr artifact version --group my-schemas --artifact my-artifact -
Create a new version from a file:
$ acr artifact version create 2.0.0 --file schema-v2.avsc --group my-schemas --artifact my-artifactIf you omit the version identifier, the server generates one. To create the version in the
DRAFTstate, use the--draftoption. -
Get a version. The version expression is an explicit version identifier, such as
2.0.0, or a branch expression, such asbranch=latest:$ acr artifact version get 2.0.0 --group my-schemas --artifact my-artifactTo retrieve the version content instead of the metadata, use the
--content(-c) option. -
Update the metadata or state of a version:
$ acr artifact version update 2.0.0 --group my-schemas --artifact my-artifact --state DEPRECATEDThe
--stateoption accepts the following values:ENABLED,DISABLED,DEPRECATED, andDRAFT. To update the content of a version, use the--fileoption. Content updates are only possible for versions in theDRAFTstate. -
Delete a version:
$ acr artifact version delete 2.0.0 --group my-schemas --artifact my-artifactYou must configure Apicurio Registry with
apicurio.rest.deletion.artifact-version.enabled=trueto allow version deletions.
Managing rules using the CLI
You can use the CLI to manage content rules at the global, group, and artifact levels. Rules at a more specific level override rules at a broader level.
-
You have configured at least one CLI context.
-
Manage global rules with the
acr rulecommands:$ acr rule create VALIDITY --config FULL $ acr rule $ acr rule get VALIDITY $ acr rule update VALIDITY --config SYNTAX_ONLY $ acr rule delete VALIDITY -
Manage the rules of a group with the
acr group rulecommands:$ acr group rule create COMPATIBILITY --config BACKWARD --group my-schemas -
Manage the rules of an artifact with the
acr artifact rulecommands:$ acr artifact rule create INTEGRITY --config FULL --group my-schemas --artifact my-artifact -
Optional: Delete all rules at a level by using the
--alloption:$ acr rule delete --allFor the valid rule types and configuration values, see the rule types table in the CLI reference section.
Managing role mappings using the CLI
You can use the CLI to assign Apicurio Registry roles to principals, such as user accounts or service accounts, when role-based authorization is enabled on the registry.
-
You have configured a CLI context for a Apicurio Registry instance with role-based authorization enabled.
-
You are authenticated as a user with permission to manage role mappings.
-
Create a role mapping for a principal. The role is one of
ADMIN,DEVELOPER, orREAD_ONLY:$ acr role create service-account-my-app DEVELOPEROptional: Provide a display name with the
--nameoption. -
List all role mappings:
$ acr role -
Get the role mapping of a principal:
$ acr role get service-account-my-app -
Update the role of a principal:
$ acr role update service-account-my-app --role ADMIN -
Delete a role mapping:
$ acr role delete service-account-my-app
Exporting and importing data using the CLI
You can use the CLI to export Apicurio Registry data to a .zip file and to import previously exported data into a registry instance.
-
You have configured at least one CLI context.
-
Export all registry data to a .zip file:
$ acr admin export --file registry-export.zip -
Optional: Export the data of a single group by using the
--groupoption:$ acr admin export --file group-export.zip --group my-schemas -
Import registry data from a .zip file:
$ acr admin import --file registry-export.zipOptional: To import into a registry that already contains data, use the
--no-require-emptyoption. To let the server generate new global and content identifiers instead of preserving the exported ones, use the--no-preserve-idsoption.
CLI output formats and pagination
The CLI supports different output formats, pagination, ordering, and column selection options for managing command output.
The CLI supports the following output formats:
-
table(default) - Human-readable tabular format -
json- Machine-readable JSON format
To specify the output format, use the --output-type or -o option:
$ acr group --output-type json
$ acr group get my-schemas -o json
The acr content command is an exception: its output types are raw (default) and json.
In JSON mode, the CLI writes only data to standard output and diverts status messages to standard error, which makes the output suitable for scripting.
For commands that return lists, you can use pagination options:
-
--page- The page number, starting from 1 (default: 1) -
--size- The number of items per page (default: 10)
For example:
$ acr group --page 2 --size 25
List commands also support ordering with the --order-by and --order options. The default sort order is ascending (Asc), and the default sort field depends on the command.
Selecting columns
For commands that list results in a table (for example acr artifact, acr group, and the acr search commands), you can choose which columns to show by using the --columns option. It takes a comma-separated list of column names, matched case-insensitively:
$ acr artifact --columns groupId,artifactId,name
$ acr artifact version --columns version,state,createdOn
An unknown column name produces an error that lists the valid columns. This option only affects table output, and is available on commands that list multiple records rather than commands that show details of a single record.
Verbose output
To enable verbose output for debugging, use the --verbose option. This option has no short form.
CLI reference
The following tables describe CLI global options, exit codes, available commands, rule types, and CLI configuration properties.
The following options are available for most CLI commands:
| Option | Description |
|---|---|
|
Enable verbose output for debugging. This option has no short form. |
|
Display help information for the command. |
|
Set the output format. Valid values are |
The CLI uses the following exit codes:
| Code | Description |
|---|---|
0 |
Successful execution. |
1 |
Application error. |
2 |
Input validation error. |
3 |
Apicurio Registry server error. |
The following commands are available. Running a parent command, such as acr group, without a subcommand lists the corresponding records.
| Command | Description |
|---|---|
|
List contexts. Subcommands: |
|
List CLI configuration properties. Subcommands: |
|
Log in to the current context by using basic authentication or OAuth2 client credentials. |
|
Log out of the current context and remove stored credentials. |
|
List groups. Subcommands: |
|
List the rules of a group. Subcommands: |
|
List the artifacts of a group. Subcommands: |
|
List the rules of an artifact. Subcommands: |
|
List the versions of an artifact. Subcommands: |
|
Work with version comments. Subcommands: |
|
List the outbound references of a version. Use the |
|
List global rules. Subcommands: |
|
List role mappings. Subcommands: |
|
Search groups by identifier, description, or labels. Alias: |
|
Search artifacts by name, description, group, type, labels, or identifiers. Alias: |
|
Search versions, with additional version and state filters. Alias: |
|
Search artifacts by content from a file or standard input. Supports canonical content matching with the |
|
Retrieve content by global ID, content ID, or SHA-256 hash. |
|
List the dynamic configuration properties of the Apicurio Registry server. Subcommands: |
|
Export registry data to a .zip file, optionally limited to one group. |
|
Import registry data from a .zip file. |
|
Install the CLI for the current user. |
|
Update the CLI to a newer version. |
|
Display CLI version information and, if the server is reachable, server version information. |
The rule commands accept the following rule types and configuration values:
| Rule type | Configuration values |
|---|---|
|
|
|
|
|
|
You can adjust the behavior of the CLI itself with the acr config set command. The following CLI configuration properties are available:
| Property | Default | Description |
|---|---|---|
|
|
Check for CLI updates once per day. |
|
|
Timeout for update operations, in seconds. |
|
|
Skip checksum verification when updating the CLI. |
