]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
examples/rgw: register boto extension for HeadBucket stats 60847/head
authorCasey Bodley <cbodley@redhat.com>
Tue, 26 Nov 2024 16:51:38 +0000 (11:51 -0500)
committerCasey Bodley <cbodley@redhat.com>
Tue, 17 Dec 2024 20:28:52 +0000 (15:28 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
examples/rgw/boto3/head_bucket_stats.py [new file with mode: 0755]
examples/rgw/boto3/service-2.sdk-extras.json

diff --git a/examples/rgw/boto3/head_bucket_stats.py b/examples/rgw/boto3/head_bucket_stats.py
new file mode 100755 (executable)
index 0000000..1de40d6
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+
+import boto3
+import sys
+
+if len(sys.argv) != 2:
+    print('Usage: ' + sys.argv[0] + ' <bucket>')
+    sys.exit(1)
+
+# bucket name as first argument
+bucketname = sys.argv[1]
+
+# endpoint and keys from vstart
+endpoint = 'http://127.0.0.1:8000'
+access_key='0555b35654ad1656d804'
+secret_key='h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=='
+
+client = boto3.client('s3',
+        endpoint_url=endpoint,
+        aws_access_key_id=access_key,
+        aws_secret_access_key=secret_key)
+
+# reading bucket stats via HeadBucket
+
+response = client.head_bucket(Bucket=bucketname, ReadStats=True)
+
+print('Objects:', response['ObjectCount'], 'Bytes:', response['BytesUsed'])
index b81667ecd090ba1314ac1ae4c3a7817346932b8c..4618543d61baf38d88362f2967a436cef9df2795 100644 (file)
             },
             "documentation":"<p>A filter for all log object. Filter for the object by its key (prefix, suffix and regex).</p>",
             "locationName":"Filter"
-        }
+        },
+        "HeadBucketRequest": {
+            "members": {
+                "ReadStats":{
+                    "shape":"ReadStats",
+                    "documentation":"<p>Read additional usage statistics for <code>ObjectCount</code> and <code>BytesUsed</code> in the response.</p> <note> <p>This request parameter is a Ceph RGW extension.</p> </note>",
+                    "location":"querystring",
+                    "locationName":"read-stats"
+                }
+            }
+        },
+        "HeadBucketOutput":{
+            "members":{
+                "ObjectCount":{
+                    "shape":"ObjectCount",
+                    "documentation": "<p>Total number of objects/versions in the bucket.</p>",
+                    "location": "header",
+                    "locationName": "x-rgw-object-count"
+                },
+                "BytesUsed":{
+                    "shape":"BytesUsed",
+                    "documentation": "<p>Total size in bytes of all objects/versions in the bucket.</p>",
+                    "location": "header",
+                    "locationName": "x-rgw-bytes-used"
+                }
+            }
+        },
+        "ReadStats":{"type":"boolean"},
+        "ObjectCount":{"type":"integer"},
+        "BytesUsed":{"type":"integer"}
     },
     "documentation":"<p/>"
 }