Sort function

For RESTful API services, you can sort the output of your query.

The following example shows a query without the sort function:

curl -k -s -v "https://lynx.tuc.stglabs.ibm.com/api/v2/dataClasses" -H "Authorization: Bearer xxxxx" 
Note: The provided curl command syntax may not work under Windows environment, it depends on the application to run the curl command. You may need to adjust the command syntax if it does not work.

The response that you get looks like this:

[
  {
    "lwormRetentionOptions": null,
    "name": "--------",
    "counterHandling": "surfaceEOT",
    "description": "The default Data Class",
    "compression": "FICON",
    "logicalWorm": "yes",
    "virtualVolumeSize": 25000
  },
  {
    "lwormRetentionOptions": {
      "retentionType": "FIXED",
      "fixedDuration": 99,
      "applicationManagedDuration": null,
      "applyFixedDurationForFirstHDR1NoDate": null,
      "applyFixedDurationOnReturnToScratch": "yes",
      "applyApplicationManagedDateForSubsequentHDR1": null,
      "honorAllSubsequentHDR1s": null,
      "noFirstHDR1TreatAsNoDate": null,
      "honorReturnToScratch": "yes",
      "applyFixedDurationForSubsequentHDR1NoDate": null,
      "applyFixedDurationForNoSubsequentHDR1": null
    },
    "name": "ABC123",
    "counterHandling": "wrapSupported",
    "description": "",
    "compression": "FICON",
    "logicalWorm": "yes",
    "virtualVolumeSize": 6000
  },
...
  {
    "lwormRetentionOptions": null,
    "name": "TESTTEST",
    "counterHandling": "surfaceEOT",
    "description": "Auto created by mount of volume B01230 at 2023.08-31.15:11:18.560881",
    "compression": "FICON",
    "logicalWorm": "no",
    "virtualVolumeSize": 0
  },
  {
    "lwormRetentionOptions": null,
    "name": "ZBADDTSZ",
    "counterHandling": "surfaceEOT",
    "description": "Robot Framework POST Test Of Valid Data",
    "compression": "ZSTD",
    "logicalWorm": "no",
    "virtualVolumeSize": 0
  }
]

Now, for example, to get the output sorted by virtualVolumeSize, you can run:

curl -k -s -v "https://lynx.tuc.stglabs.ibm.com/api/v2/dataClasses?sort=virtualVolumeSize" -H "Authorization: Bearer xxxxx"

Then, you get the following response:

[
  {
    "lwormRetentionOptions": {
      "retentionType": "FIXED",
      "fixedDuration": 1,
      "applicationManagedDuration": null,
      "applyFixedDurationForFirstHDR1NoDate": null,
      "applyFixedDurationOnReturnToScratch": "no",
      "applyApplicationManagedDateForSubsequentHDR1": null,
      "honorAllSubsequentHDR1s": null,
      "noFirstHDR1TreatAsNoDate": null,
      "honorReturnToScratch": "no",
      "applyFixedDurationForSubsequentHDR1NoDate": null,
      "applyFixedDurationForNoSubsequentHDR1": null
    },
    "name": "ABC456",
    "counterHandling": "wrapSupported",
    "description": "",
    "compression": "ZSTD",
    "logicalWorm": "yes",
    "virtualVolumeSize": 0
  },
  {
    "lwormRetentionOptions": {
      "retentionType": "HDR1",
      "fixedDuration": 1,
      "applicationManagedDuration": 1,
      "applyFixedDurationForFirstHDR1NoDate": "yes",
      "applyFixedDurationOnReturnToScratch": "yes",
      "applyApplicationManagedDateForSubsequentHDR1": "yes",
      "honorAllSubsequentHDR1s": "yes",
      "noFirstHDR1TreatAsNoDate": "yes",
      "honorReturnToScratch": "yes",
      "applyFixedDurationForSubsequentHDR1NoDate": "yes",
      "applyFixedDurationForNoSubsequentHDR1": "yes"
    },
    "name": "DC000",
    "counterHandling": "wrapSupported",
    "description": "Tests2",
    "compression": "FICON",
    "logicalWorm": "yes",
    "virtualVolumeSize": 0
  },
...
  {
    "lwormRetentionOptions": {
      "retentionType": "FIXED",
      "fixedDuration": 99,
      "applicationManagedDuration": null,
      "applyFixedDurationForFirstHDR1NoDate": null,
      "applyFixedDurationOnReturnToScratch": "yes",
      "applyApplicationManagedDateForSubsequentHDR1": null,
      "honorAllSubsequentHDR1s": null,
      "noFirstHDR1TreatAsNoDate": null,
      "honorReturnToScratch": "yes",
      "applyFixedDurationForSubsequentHDR1NoDate": null,
      "applyFixedDurationForNoSubsequentHDR1": null
    },
    "name": "ABC123",
    "counterHandling": "wrapSupported",
    "description": "",
    "compression": "FICON",
    "logicalWorm": "yes",
    "virtualVolumeSize": 6000
  },
  {
    "lwormRetentionOptions": null,
    "name": "--------",
    "counterHandling": "surfaceEOT",
    "description": "The default Data Class",
    "compression": "FICON",
    "logicalWorm": "yes",
    "virtualVolumeSize": 25000
  },
  {
    "lwormRetentionOptions": null,
    "name": "DC25G",
    "counterHandling": "wrapSupported",
    "description": "",
    "compression": "ZSTD",
    "logicalWorm": "no",
    "virtualVolumeSize": 25000
  }
]

As you can see, the REST API provides the data that is ordered by virtualVolumeSize (0 → 25000). You can reverse the order with virtualVolumeSize (25000 → 0) when ('-' is added):

curl -k -s -v "https://lynx.tuc.stglabs.ibm.com/api/v2/dataClasses?sort=-virtualVolumeSize" -H "Authorization: Bearer xxxxx"

The response shows the following order:

[
  {
    "lwormRetentionOptions": null,
    "name": "--------",
    "counterHandling": "surfaceEOT",
    "description": "The default Data Class",
    "compression": "FICON",
    "logicalWorm": "yes",
    "virtualVolumeSize": 25000
  },
  {
    "lwormRetentionOptions": null,
    "name": "DC25G",
    "counterHandling": "wrapSupported",
    "description": "",
    "compression": "ZSTD",
    "logicalWorm": "no",
    "virtualVolumeSize": 25000
  },
  {
    "lwormRetentionOptions": {
      "retentionType": "FIXED",
      "fixedDuration": 99,
      "applicationManagedDuration": null,
      "applyFixedDurationForFirstHDR1NoDate": null,
      "applyFixedDurationOnReturnToScratch": "yes",
      "applyApplicationManagedDateForSubsequentHDR1": null,
      "honorAllSubsequentHDR1s": null,
      "noFirstHDR1TreatAsNoDate": null,
      "honorReturnToScratch": "yes",
      "applyFixedDurationForSubsequentHDR1NoDate": null,
      "applyFixedDurationForNoSubsequentHDR1": null
    },
    "name": "ABC123",
    "counterHandling": "wrapSupported",
    "description": "",
    "compression": "FICON",
    "logicalWorm": "yes",
    "virtualVolumeSize": 6000
  },
...
  {
    "lwormRetentionOptions": null,
    "name": "TESTTEST",
    "counterHandling": "surfaceEOT",
    "description": "Auto created by mount of volume B01230 at 2023.08-31.15:11:18.560881",
    "compression": "FICON",
    "logicalWorm": "no",
    "virtualVolumeSize": 0
  },
  {
    "lwormRetentionOptions": null,
    "name": "ZBADDTSZ",
    "counterHandling": "surfaceEOT",
    "description": "Robot Framework POST Test Of Valid Data",
    "compression": "ZSTD",
    "logicalWorm": "no",
    "virtualVolumeSize": 0
  }
]

Also, you can sort on multiple orders. For example:

curl -k -s -v "https://lynx.tuc.stglabs.ibm.com/api/v2/dataClasses?sort=virtualVolumeSize,compression" -H "Authorization: Bearer xxxxx"
Now, the output of the query is ordered by virtualVolumeSize, then compression.
Note: Compression is string, so it sorts it in alphabetical order (A → Z)
[
  {
    "lwormRetentionOptions": {
      "retentionType": "HDR1",
      "fixedDuration": 1,
      "applicationManagedDuration": 1,
      "applyFixedDurationForFirstHDR1NoDate": "yes",
      "applyFixedDurationOnReturnToScratch": "yes",
      "applyApplicationManagedDateForSubsequentHDR1": "yes",
      "honorAllSubsequentHDR1s": "yes",
      "noFirstHDR1TreatAsNoDate": "yes",
      "honorReturnToScratch": "yes",
      "applyFixedDurationForSubsequentHDR1NoDate": "yes",
      "applyFixedDurationForNoSubsequentHDR1": "yes"
    },
    "name": "DC000",
    "counterHandling": "wrapSupported",
    "description": "Tests2",
    "compression": "FICON",
    "logicalWorm": "yes",
    "virtualVolumeSize": 0
  },
  {
    "lwormRetentionOptions": null,
    "name": "MYTEST",
    "counterHandling": "surfaceEOT",
    "description": "A whole new test",
    "compression": "FICON",
    "logicalWorm": "no",
    "virtualVolumeSize": 0
  },
...
  {
    "lwormRetentionOptions": null,
    "name": "--------",
    "counterHandling": "surfaceEOT",
    "description": "The default Data Class",
    "compression": "FICON",
    "logicalWorm": "yes",
    "virtualVolumeSize": 25000
  },
  {
    "lwormRetentionOptions": null,
    "name": "DC25G",
    "counterHandling": "wrapSupported",
    "description": "",
    "compression": "ZSTD",
    "logicalWorm": "no",
    "virtualVolumeSize": 25000
  }
]