Command Line tool for importing and exporting APIs/Applications/API Products in between different API environments of WSO2 API Manager and managing WSO2 Micro Integrator
-
Setting up the development environment
- Install Go 1.22
- Fork the repository
- Clone your fork into any directory
cd
into cloned directory and then cd into product-apim-tooling/import-export-cli
- Execute
go mod vendor
or go mod download
to download all the dependencies - Run
go generate ./...
to pack resources - Run
go build apictl.go
to build and test program
-
Building
cd
into product-apim-tooling/import-export-cli
Execute ./build.sh -t apictl.go -v 4.5.0 -f
to build for all platforms.
Created packages will be available at build/target
directory
-
Resources
All the resources(Markdown files, templates etc) need to be stored inside box/resources directory
You can create sub directories as you like.
Run go generate ./...
to bake your files into go files.
Then refer to them using box.Get(filename)
. Always use relative path to resources directory with a leading slash(/)
For example: For a file in box/resources/init/file
you can retrieve it using box.Get("/init/file)
DO NOT COMMIT blob.go to VCS
-
Generating docs
After changing commands run following to generate documents and shell completions
go run tools/gen.go
If you need to generate docs and shell completions for MI CLI run the following
MICmd=mi go run tools/migen.go
Commit changes to version control
-
Running
Select a generated archive suitable for your platform (Mac, Windows, Linux) and extract it to a desired location andcd
into it.
Then execute apictl
to start the application.
NOTE: Execute ./apictl
if the working directory is the same where the executable resides
Add the location of extracted folder to your system's $PATH variable to access the executable from anywhere
Execute apictl --help
for further instructions.
-
Adding Environments
Add environments by either manually editing $HOME/.wso2apictl/main_config.yaml
or using the command
apictl add-env
.
NOTE: Directory structure for configuration files ($HOME/.wso2apictl
) will be created upon execution of apictl
Execute apictl add-env --help
for detailed instructions
The flag --environment
(-e) is mandatory
You can either provide only the --apim
flag, or all the other 5 flags (--registration
--publisher
--devportal
--admin
--token
) without providing --apim
flag.
If you are omitting any of --registration --publisher --devportal --admin flags, you need to specify --apim flag with the API Manager endpoint.
To add a micro integrator instance to an environment you can use the --mi
flag.
-
Command Autocomplete
Copy the file shell-completions/apictl_bash_completion.sh
to /etc/bash_completion.d/
and source it with
source /etc/bash_completion.d/apictl_bash_completion.sh
to enable bash auto-completion.
-
Building a Docker Image of APICTL
Usage: docker build --build-arg version=<version> -t apictl:<version> .
Example: docker build --build-arg version=4.5.0.1 -t apictl:4.5.0.1 .