Managing Choreo Connect¶
WSO2 API Controller (apictl) can be used as a developer CLI tool for Choreo Connect. It enables interacting with one or more Choreo Connect environments without having to perform the following tasks via the WSO2 API Manager (WSO2 API-M).
- Deploy an API
- View the list of deployed APIs
- Undeploy an API
Info
Before you begin
-
Download the Choreo Connect distribution from the github release page's and follow the Quick Start Guide attached with the release.
-
Make sure the apictl is downloaded and initialized, if not follow the steps in Download and Initialize the apictl. Following the guide upto Check the version of the apictl will be sufficient to continue.
-
Remember to add the cert of Choreo Connect into
/home/<your-pc-username>/.wso2apictl/certsto communicate via https (to avoid having to use insecure mode with -k or --insecure). Click here for more information.
Add a Choreo Connect Environment¶
A Choreo Connect here refers to the entire cluster which includes all three components: adapter, router and enforcer. By adding a Choreo Connect environment, the URL to the adapter will be stored in a configuration file, and therefore enables login.
Once you have added a Choreo Connect environment, and logged in, other commands such as apictl mg deploy api can be used by only specifying an environment. This allows you to use such commands without entering the Choreo Connect adapter URL, username, and password every time.
-
Command
Info
Flags:
- Mandatory :
--adapteror-a: The Choreo Connect adapter host url with port
- Mandatory :
Log in to a Choreo Connect Environment¶
Log in will get an access token from the Choreo Connect adapter and store it for further commands.
-
Command
Tip
If you run
apictl mg login <environment-name>you are prompted to provide both the username and the password. If you runapictl mg login <environment-name> --username <username>, you are prompted to provide the password. If you include the flag--password-stdin, you can provide the password in a file as well. For an example,Info
Flags:
- Optional :
--usernameor-u: Username for login
--passwordor-p: Password for login
--password-stdin: Get password from stdin
Example
-
Response
Warning
Using
--passwordin CTL is not secure. Instead, you can use--password-stdinto include password file or provide the password when prompted. - Optional :
Deploy an API¶
In order to deploy, let us first create an API project. Follow the steps in Initialize an API Project to create an API project using apictl.
An API project can be deployed to a Choreo Connect using the following commands.
-
Command
Tip
In an API project, the API name and the API version given in the
api.yamlwill be taken as the name and version of the API once deployed.Tip
When trying to deploy, if an API with the same name, version, virtual host combination already exists in the Choreo Connect adapter, an error response will be given saying that the API already exists.
In order to override the existing API or deploy an API without considering whether it already exists or not, include the flag
--overrideor its shorthand-oto the same command above. For an example,Info
Flags:
-
Mandatory :
-e,--environment: Choreo Connect adapter environment to add the API
-f,--file: Filepath of the apictl project to be deployed -
Optional :
-o,--override: Whether to deploy an API irrespective of its existence. Overrides when exists.
--skip-cleanup: Whether to keep all temporary files created during the deploy process
-
-
Response
List Deployed APIs¶
This command can be used to list the deployed APIs on a given Choreo Connect adapter environment.
-
Command
Tip
By default, the number of APIs listed will be limited to 25. To increase or decrease the limit set the flag
--limitor its shorthand flag-l. For an example,Tip
Currently, these APIs can be filtered by API type. The supported types are http and ws (web socket). Use the flag
--queryor its shorthand flag-qto filter APIs.Info
Flags:
-
Mandatory :
-e,--environment: Choreo Connect adapter environment to list the APIs from -
Optional :
-l,--limit: Maximum number of APIs to return
-q,--query: Query to filter the APIs
-
-
Response
Undeploy an API¶
This command can be used to remove an API from the Choreo Connect.
-
Command
Info
Flags:
-
Mandatory :
-e,--environment: Choreo Connect adapter environment to undeploy the API from
-n,--name: API name
-v,--version: API version -
Optional :
-t,--vhost: Virtual host the API belongs to
Example
- Response
-
Log out from a Choreo Connect Environment¶
This command can be used to logout from a Choreo Connect adapter environment. Once this command is executed, the access token of the Choreo Connect adapter will be erased from apictl.
-
Command
- Response
Remove a Choreo Connect Environment¶
This command can be used to remove a Choreo Connect environment from apictl. Once this command is executed, it will delete the adapter URL and its access token first, and then remove the Choreo Connect environment from apictl.
-
Command
-
Response