errose28 commented on code in PR #4157:
URL: https://github.com/apache/ozone/pull/4157#discussion_r1093769144


##########
hadoop-hdds/docs/content/interface/Cli.md:
##########
@@ -207,3 +207,59 @@ $ ozone sh key info /vol1/bucket1/README.md
 ```shell
 $ ozone sh key get /vol1/bucket1/README.md /tmp/
 ```
+
+## Querying Cli Results
+
+Ozone cli returns JSON responses. [jq](https://stedolan.github.io/jq/manual/) 
is a command line JSON processor that can be used to filter cli output for 
desired information.
+
+For example: 
+```shell
+# List encrypted bucket names
+$ ozone sh bucket list /vol1 | jq -r '.[] | select(.encryptionKeyName != null) 
| [.name, .encryptionKeyName] | @tsv'
+ec5     key1
+encrypted-bucket        key1
+
+# List EC buckets with replication config
+$ $ ozone sh bucket list /vol1 | jq -r '.[] | 
select(.replicationConfig.replicationType == "EC") | [.name, 
.replicationConfig]'
+[
+  "ec5",
+  {
+    "data": 3,
+    "parity": 2,
+    "ecChunkSize": 1048576,
+    "codec": "RS",
+    "replicationType": "EC",
+    "requiredNodes": 5
+  }
+]
+[
+  "ec9",
+  {
+    "data": 6,
+    "parity": 3,
+    "ecChunkSize": 1048576,
+    "codec": "RS",
+    "replicationType": "EC",
+    "requiredNodes": 9
+  }
+]
+
+# List FSO buckets that are not links
+$ ozone sh bucket list /s3v | jq '.[] | select(.link==false and 
.bucketLayout=="FILE_SYSTEM_OPTIMIZED")'
+{
+  "metadata": {},
+  "volumeName": "s3v",
+  "name": "fso-bucket",
+  "storageType": "DISK",
+  "versioning": false,
+  "usedBytes": 0,
+  "usedNamespace": 0,
+  "creationTime": "2023-02-01T05:18:46.974Z",
+  "modificationTime": "2023-02-01T05:18:46.974Z",
+  "quotaInBytes": -1,
+  "quotaInNamespace": -1,
+  "bucketLayout": "FILE_SYSTEM_OPTIMIZED",
+  "owner": "om",
+  "link": false
+}
+```

Review Comment:
   The three chosen examples are good. I just have some minor suggestions for 
readability. Mostly reordering them from least complex to most complex and 
splitting them into bullets since most people skim docs. I typed the markdown 
here directly so it would render in the comment.
   
   - List FSO buckets that are not links
   ```shell
   $ ozone sh bucket list /s3v | jq '.[] | select(.link == false and 
.bucketLayout == " FILE_SYSTEM_OPTIMIZED")'
   {
     "metadata": {},
     "volumeName": "s3v",
     "name": "fso-bucket",
     "storageType": "DISK",
     "versioning": false,
     "usedBytes": 0,
     "usedNamespace": 0,
     "creationTime": "2023-02-01T05:18:46.974Z",
     "modificationTime": "2023-02-01T05:18:46.974Z",
     "quotaInBytes": -1,
     "quotaInNamespace": -1,
     "bucketLayout": "FILE_SYSTEM_OPTIMIZED",
     "owner": "om",
     "link": false
   }
   ```
   
   - List EC bucket names with their replication type.
   ```shell
   ozone sh bucket list /vol1 | jq -r '.[] | 
select(.replicationConfig.replicationType == "EC") | {"name": .name, 
"replicationType": .replicationConfig.replicationType}'
   {
     "name": "ec5",
     "replicationType": "EC"
   }
   {
     "name": "ec9",
     "replicationType": "EC"
   }
   ```
   
   - List names of encrypted buckets and their encryption key names in 
tab-separated-value format.
   ```shell
   $ ozone sh bucket list /vol1 | jq -r '.[] | select(.encryptionKeyName != 
null) | [.name, .encryptionKeyName] | @tsv'
   ec5     key1
   encrypted-bucket        key1
   ```
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to