xapixctl
is the Xapix command line tool that includes a client library you use to run tasks on a command line or in a batch file. Normally, these tasks are done in the Xapix UI.
With these commands you can create scripts and then automate sets of tasks depending on your requirements.
Installing xapixctl
is very simple. Just run the following command and you are ready to go:
$ gem install xapixctl
xapixctl
requires Ruby installed on your system.
Before you can use xapixctl, you need to set the environment variables. These include
API access token, which is specific to a Xapix user account
Xapix URL, which is specific to a project
These environment variables can be set in your OS or they can be set once per session. If they are set in your OS, you need not set them each time you open a session. However, this assumes the same environment variables will be used every time xapixctl is run.
If you have several Xapix accounts and/or several Xapix projects, setting them once per session might be a better option. Instructions for setting these environment variables are provided below.
To use xapixctl
, add your API Access Token to your environment variables of your OS.
Log in to your Xapix account.
Click the User Profile icon (upper right corner).
In the API Access Token pane, click the Copy icon.
Procedures for setting the API access token in the OS depend on which OS you are using. Consult the relevant documentation.
xapix-token=<XAPIX_TOKEN>
To set the API access token for a session, add the following option to a xapixctl
command.
[--xapix-token=XAPIX_TOKEN]
# Example Command#xapixctl api-resources --xapix-token=XAPIX_TOKEN## where XAPIX_TOKEN is your API Access token
You can set a Xapix URL as an environment variable, such as https://cloud.xapix.io/.
Alternately, you can set it for a one-time only use when running a command as shown below.
[--xapix-url=XAPIX_URL]# Fallback: environment variable XAPIX_URL. URL to Xapix.# Default: https://cloud.xapix.io/​
Command | Description |
| Help on the command line. |
| Available resource types. |
| Create or update resources. |
| Delete resources in a file. |
| Export all resources in a project. |
| Export resources of given type and id. |
| Publish current version of project. |
Obtain help on how to use xapixctl on the command line.
xapixctl help [command]
[command]
Retrieves help for the specified command. If no command is given, a list of commands is provided.
Lists all available resources.
None.
The following shows the output from running the command.
$ xapixctl api-resourcesType Required ContextAmbassador ProjectApiPublishing ProjectApiPublishingRole ProjectAuthScheme ProjectCacheConnection ProjectCredential ProjectDataSource ProjectEndpoint ProjectEndpointGroup ProjectPipeline ProjectProject OrganizationProxy ProjectSchema ProjectStream ProjectStreamGroup Project​
This list shows the TYPE and context for the TYPE.
Example 1: The TYPE Project is within the context Organization. This means a Project can only be within the context Organization.
Example 2: The TYPE Datasource can only be within the context Project.
Creates a new resource or updates an existing resource in the specified organization. If no project is given, the command applies to the project or projects specified in the file. New resources are created if none exists.
Resources are matched using TYPE and ID. Updates a resource if a resource has the same TYPE and ID exists.
xapixctl apply --file=FILE--org=ORG[--project=PROJECT][--verbose]
--file -f
YAML or JSON file used to update or create a resource. It can contain multiple projects.
--org -o
Slug of an organization to apply the resource.
--project, -p
Slug of project to apply the resource.
--verbose, -v
Write message stream to terminal.
Update the project my-first-project
in the organization my-org
with the resources (which are datasources) in vehicle_demo_swagger.yaml
.
$ xapixctl apply -v --org my-org -p my-first-project -f <path>/vehicle_demo_swagger.yaml
Deletes all resources listed in the file or deletes resources by TYPE and ID.
xapixctl delete --org=ORG[TYPE ID][--project=PROJECT][--file=FILE][--verbose]
--org, -o
Slug of the organization to which delete command will be applied.
[TYPE ID]
Provide the TYPE of API resource (see xapix api-resource
) and the ID of the resource (see xapixctl get
).
--project, -p
Slug of project to which the delete command will be applied.
--file, -f
File which provides the resources to be deleted.
--verbose, -v
Write message stream to terminal.
Exports a list of all resources of a given TYPE in a given project.
xapixctl export --org=ORG--project=PROJECT[--format=FORMAT][--verbose]
--org, -f
slug of organization from which to export a list of all resources of a given TYPE.
--project, -p
slug of project from which to export a list of all resources of a given type.
--format, -f
Format of exported resources. Can be either JSON or YAML.
--verbose, -v
Write message stream to terminal.
Export resources from the project some-project
in the organization xapix
.
xapixctl export -o xapix -p some-project
Export resources from the project some-project
in the organization xapix
and save output to the file some_project.yaml
.
xapctl export -o xapix -p some-project -f yaml > some_project.yaml
Export the resources from the project my-first-project
in the organization my-org
. This is the project created in the Quickstart tutorial.
$ xapixctl export --org my-org -p my-first-projectid : my-first-projectkind: Projectname: My First Project​id : <redacted>kind: Schemaname:​id : allvariantskind: DataSource/RESTname: allVariants​id : findenginebyidkind: DataSource/RESTname: findEngineById​id : findmodelbyidkind: DataSource/RESTname: findModelById​id : findvariantbyidkind: DataSource/RESTname: findVariantById​id : get-xapix-io-api-data-vehicle-demo-engines-engine_id-jsonkind: Endpoint/RESTname: get​id : my-first-projectkind: ApiPublishingname:
List all the resources (overview) of a specific TYPE.
xapixctl get --org=ORGTYPE[--project=PROJECT][--format=FORMAT][ID]
--org, -o
Organization to which the request is done.
TYPE
Requests on an organization are done on a project. Requests on a project can be done on a TYPE within the Project context.
For a list of types, see xapixctl api-resources.
--project, -p
Project to which the request is done.
--format, -f
Format of exported resources. Can be either JSON or YAML.
ID
TYPE id.
Retrieve the name of a project, if only the slug is available.
xapixctl get --org my-org -p my-first-project Projectid : my-first-projectkind: Projectname: My First Project
Retrieve a list of resources of the type Datasource. Both organization and project slugs are required. These are resources from Connectors in the Quickstart tutorial.
$ xapixctl get --org my-org -p my-first-project DataSourceid : allvariantskind: DataSource/RESTname: allVariants​id : findenginebyidkind: DataSource/RESTname: findEngineById​id : findmodelbyidkind: DataSource/RESTname: findModelById​id : findvariantbyidkind: DataSource/RESTname: findVariantById
Retrieve a list of resources in a Datasource called allVariants and output the results in a YAML format.
xapixctl get --org my-org -p my-first-project DataSource allvariants -f yaml
The output is shown below.
---version: v1kind: DataSource/RESTmetadata:id: allvariantsproject: my-first-projectdefinition:name: allVariantsurl: <redacted>httpMethod: getcacheTtl: 7200schema: <redacted>>parameters:- name: cookiestype: objectproperties: []- name: headertype: objectproperties: []- name: pathtype: objectproperties: []- name: querytype: objectproperties: []attributes:- name: bodytype: object[]properties:- name: base_price_EURtype: floatsample: 23456.78- name: engine_type_idtype: integersample: 547290- name: extrastype: string[]sample: ''- name: fuel_consumption_lkmtype: floatsample: 12.6- name: in_stocktype: booleansample: true- name: model_idtype: integersample: 947432- name: topspeed_kmhtype: integersample: 220- name: variant_idtype: stringsample: QLM_KROSUS_4_DOORS_LIMO​
Publishes the current status of a given project.
xapixctl publish --org=ORG --project=PROJECT
--org, -0
Slug of the organization in which the project exists which will be published by the command.
--project, -p
Slug of project to be published.
Bug reports and pull requests are welcome on GitHub at https://github.com/xapix-io/xapixctl.