The import command will create a new complete service based on the OpenAPI Spec json file that is stored under version control: api/alerts-spec.json. Documentation for constructing a service spec file can be found in the OpenAPI-Specification/3.0.2 GitHub.
3scale import openapi [opts] -d <destination> <spec>
$ toolbox 3scale import openapi -t weather-alerts --default-credentials-userkey=dummykey -d $DEST api/alerts-spec.json
the -t
flag specifies the internal system name, so the title field can be used as the 'friendly name' of the service. The output provides the service id and echos the service system name which will be needed to manipulate the service later. Each path will have a cooresponding method created and the name can be specified by operationId
in the
Created service id: 3, name: Weather Alerts API
Service proxy updated
destroying all mapping rules
Created GET /alerts/active$ endpoint
Created GET /alerts/active/area/{state}$ endpoint
Service policies updated
If the API (under version control) is ever updated, this same command will recreate the service with the new definitions provided the name of the API in the spec file has not changed.
3scale application-plan apply [opts] <remote> <service> <plan>
$ toolbox 3scale application-plan apply -n "Weather Alerts Plan" --default $DEST weather-alerts weather-plan
$ toolbox 3scale application apply --account=john --name="Weather Alerts Application" --description="Created from the CLI" --plan=weather-plan --service=weather-alerts $DEST 1234567890
The user john
is the userid of the default user created in a fresh install. The user key to access the API is 1234567890
.
From the toolbox there is not yet a complete facility to append or modify policies from the command line, only to replace with a predefined yaml. So most modifications need to be made within the admin console.
You can perform these manual steps:
- Remove the Anonymous Access policy.
- Add a URL Rewrite policy to delete the user_key argument before passing the request to the backend.
- Save the new policy chain.
...or you can use the predefined policy chain provided in this repo
$ toolbox 3scale policies import -f api/policy-chain.yaml $DEST weather-alerts
From this step you can either deploy the changes to the sandbox in the admin console or use the toolbox to do so.
$ toolbox 3scale proxy deploy $DEST weather-alerts
You can either promote the product configuration from the admin console or from the command line.
$ toolbox 3scale proxy-config promote $DEST weather-alerts
You can now test the paths of the new Product that has been created.
-
$ curl 'https://weather-alerts-3scale-apicast-staging.apps-crc.testing/alerts/active?area=KS&user_key=1234567890'
-
$ curl 'https://weather-alerts-3scale-apicast-production.apps-crc.testing/alerts/active/area/KS?user_key=1234567890'