Is there a possibility to read/set Auto-Compaction setting through Python SDK or N1QL?

Is there possibility to read/set Auto-Compaction setting through Python SDK or N1QL?
If Yes, Please share me the steps.

Actually I am using below code snippet to get all buckets information. Here I’m unable to get Auto-Compaction settings and documents count per a bucket. Kindly help me ASAP.

bucket_manager = client.buckets()
result = list(bucket_manager.get_all_buckets())

Thanks and Regards,
Srinivas

You can use couchbase-cli or REST described here Auto-Compaction | Couchbase Docs
There is no option via N1QL

Thank you very much @vsr1 for your quick suggestions.

I work for a data modeler tool. So I must need these details with SDK.
Is there a way to use REST along with Python SDK? If yes, please suggest me.

Thanks and Regards,
Srinivas

Unfortunately I don’t see anything in the API docs that references setting autocompaction through the Python SDK. It would be best to submit a ticket on the github repo: GitHub - couchbase/couchbase-python-client: Couchbase Python Client Library (Official)

Hi @SrinivasB,

Do you have any restrictions on using the Couchbase Server REST interface for the compaction independent of the SDK?

For normal SDK operations, you can use the SDK & for the compaction or other management operations, use the REST interface as suggested earlier.

Thank you very much @nithishr for your suggestions.

Actually I have tried lot to make RESTful API calls to Couchbase on Capella. But I have not yet succeeded.
Could you please suggest me how to make REST API calls (especially for GET pools/default/buckets) to Couchbase Server which is in Capella?

NOTE: I will be more happy, if SDK handles all bucket properties(including Auto-Compaction Setting) which are shown in the bucket property editor on Couchbase console at least in up coming versions.

Regards,
Srinivas.

Hi,

Thanks for the feedback regarding the SDK support for the management APIs. I would suggest creating an issue on the Python project as suggested by Perry so that it can be considered for future development.

I did not realize that you were on Capella. On Capella, we do have some restrictions on the Couchbase Server REST APIs (mainly due to the nature of managed services). Some of the endpoints requiring Admin privileges will not work. In some cases, it would be possible for them to be changed on a cluster by contacting the Support in Capella.

I can give you a general way to connect to the Couchbase Server running in Capella.

  • You need to identify the hostname of your CB Server from the UI. You can follow the guide here:Get the Capella Host Name | Couchbase Docs
  • Once you have that, you should be able to connect to the allowed REST APIs using port 18091 on the host. Note that you might have to pass in the certificate downloaded from the UI or ignore the certificate validation.
  • You can send your REST API requests to :18091

Here is an example of the pools/default/buckets endpoint that you wanted using curl. You can achieve the same in any language of your choice.

curl -k -u <db-username>:<password> -X GET https://<hostname>:18091/pools/default/buckets/ 

Note that I have ignored the validation of the certificate for simplicity.

Thank you very much @nithishr for your valuable information.

In my application, we are using Python 3.11.x. With this I am unable to disable SSL certificate validation.
If possible, Could you please suggest me how to make a RESTful api request along with ssl certificate. I have downloaded certificate from Capella.

I am very sorry for this kind of question. I am expecting help, since I am very new to SSL.

Thanks and Regards,
Srinivas

I need to check how to pass the certificate from Capella. If you want a faster response to that problem, it would be easiest to contact support via Capella.

To disable the certificate validation in the requests library in Python, you can pass a parameter, verify as False to the request.

For example, this is something you can do in Python using the requests library

import requests

resp = requests.get("https://<hostname>:18091/pools/default/buckets/", auth=(db_user, db_pass), verify=False)

print(resp.status_code, resp.text)

Achieved!!! Thank you very much @nithishr.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.