Configure REST API
You can use the Portworx Backup API to create, delete, schedule, and restore backups. This API is organized around REST and returns responses in JSON format.
To configure rest APIs, you need to expose Swagger UI and then fetch an access token for the instance.
Expose Swagger UI
To expose Swagger UI in Portworx Backup:
Expose px-backup deployment as REST interface:
$ kubectl expose deployment -n px-backup px-backup --type=NodePort --port=10001 --name px-backup-rest
Output:
service/px-backup-rest exposed
Check if the service is properly created:
$ kubectl get service -n px-backup | grep rest
Output:
px-backup-rest NodePort <node_IP> <none> 10001:<node_port>/TCP 25s
Open the swagger UI endpoint
http://(NodeIP:NodePort)/swagger-ui/
in your web browser to access the API through swagger:
Fetch an access token
To fetch the token for an instance, login with the admin credentials and then perform the following steps:
Fetch access token with the same admin credentials used for login:
curl --data 'grant_type=password&client_id=pxcentral&username=admin&password=Password1&token-duration=365d' http://<IP>:<Port>/auth/realms/master/protocol/openid-connect/token --silent | jq -r ".access_token"
Add the token:
Click Authorize on the Swagger UI page.
Add the token generated with the
Bearer
prefix and a space in between.Click Authorize on Available authorizations.
Click Close.