Public API examples

Change devices properties like password

Example with curl on how to change the IBM storwize family device storage passwords using our Xormon NG public REST API:
The first thing you will need to do is to fetch the API key, you can do so like this example:
curl --location 'https://localhost:8443/api/public/v1/auth' \
     --header 'Content-Type: application/json' \
     --data '{
              "username": "xormon",
              "password": "xormon"
}'
you will then recieve response with the api key (response is in json fromat):
{
    "statusCode": 200,
    "data": {
        "apiKey": "b2c9bcf8a16c29d50a73dd52bdcc44a6",
        "expiration": "2025-06-06T08:39:44.640Z"
    }
}
You will use then use the api key inside the header like this:
curl --location 'https://localhost:8443/api/public/v1/hostcfg/' \ 
     --header 'apiKey: b2c9bcf8a16c29d50a73dd52bdcc44a6'
This request will return all your device configurations in this format:
[
    {
            "hostcfg_id": "a7ac3eb5-95de-42c4-ba81-494835fa9ab0",
            "label": "storwize",
            "hw_type": "swiz",
            "disabled": true,
            "target": false,
            "ignore_health_status": false,
            "ignore_health_status_reason": null,
            "data": {
                "host": "",
                "alias": "storwize",
                "radio": "ssh-key-option",
                "device": "IBM__STORWIZE_FAMILY",
                "vendor": "IBM",
                "created": "2022-11-03T09:31:30Z",
                "sshPort": 22,
                "updated": "2023-10-24T09:22:36Z",
                "isKeyFile": true,
                "sampleRate": 5,
                "sshKeyFile": "",
                "sshPassword": null,
                "sshUsername": "stor2rrd"
            },
            "createdAt": "2024-08-02T13:42:16.905Z",
            "updatedAt": "2024-08-09T10:21:12.753Z",
            "hw_type_label": "Storwize",
            "limited": false
        },
]
You can filter the array for the ibm storwize storages, they will always have "device": "IBM__STORWIZE_FAMILY" inside the data: {}, they will also have hw_type: storwize
Lets get to the password updating. We will update the configuration by calling the REST API like so:
curl --location 'https://localhost:8443/api/public/v1/hostcfg/' \
     --header 'apiKey: b2c9bcf8a16c29d50a73dd52bdcc44a6' \
     --header 'Content-Type: application/json' \
     --data '{
            "hostcfg_id": "a7ac3eb5-95de-42c4-ba81-494835fa9ab0",
            "label": "storwize",
            "hw_type": "swiz",
            "disabled": true,
            "target": false,
            "ignore_health_status": false,
            "ignore_health_status_reason": null,
            "data": {
                "host": "",
                "alias": "storwize",
                "radio": "ssh-key-option",
                "device": "IBM__STORWIZE_FAMILY",
                "vendor": "IBM",
                "created": "2022-11-03T09:31:30Z",
                "sshPort": 22,
                "updated": "2023-10-24T09:22:36Z",
                "isKeyFile": true,
                "sampleRate": 5,
                "sshKeyFile": "",
                "sshPassword": "YOUR NEW PASSWORD AS STRING HERE",
                "sshUsername": "stor2rrd"
            },
        }'
Also you dont have to include many of the keys, here is the minimum working example but you will always have to include the "hostcfg_id" and every single key that is inside the data key! Like this:
curl --location 'https://localhost:8443/api/public/v1/hostcfg/' \
     --header 'apiKey: b2c9bcf8a16c29d50a73dd52bdcc44a6' \
     --header 'Content-Type: application/json' \
     --data '{
            "hostcfg_id": "a7ac3eb5-95de-42c4-ba81-494835fa9ab0",
            "data": {
                "host": "",
                "alias": "storwize",
                "radio": "ssh-key-option",
                "device": "IBM__STORWIZE_FAMILY",
                "vendor": "IBM",
                "created": "2022-11-03T09:31:30Z",
                "sshPort": 22,
                "updated": "2023-10-24T09:22:36Z",
                "isKeyFile": true,
                "sampleRate": 5,
                "sshKeyFile": "",
                "sshPassword": "YOUR NEW PASSWORD AS STRING HERE",
                "sshUsername": "stor2rrd"
            },
        }'
The key for password change for the IBM Storwize storages is sshPassword inside the data object.